forked from eatvio/eatvio-infra
20 lines
405 B
PHP
Executable File
20 lines
405 B
PHP
Executable File
<?php
|
|
|
|
namespace App\Policies;
|
|
|
|
use App\Models\Plan;
|
|
use App\Models\User;
|
|
|
|
class PlanPolicy
|
|
{
|
|
public function edit(User $user, Plan $plan): bool
|
|
{
|
|
return $this->isAuthorPlan($user, $plan) || $user->hasRole('admin') || $user->hasRole('moderator');
|
|
}
|
|
|
|
private function isAuthorPlan(User $user, Plan $plan): bool
|
|
{
|
|
return $user->id === $plan->author->first()->id;
|
|
}
|
|
}
|