2023-07-16 19:21:09 +06:00
|
|
|
<?php declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace App\Policies;
|
|
|
|
|
|
|
|
use App\Models\Role;
|
|
|
|
use App\Models\User;
|
|
|
|
|
|
|
|
final readonly class RolePolicy extends Policy
|
|
|
|
{
|
|
|
|
public function viewAny(User $user): bool
|
|
|
|
{
|
|
|
|
return $user->hasPermission('role.view');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function view(User $user, Role $role): bool
|
|
|
|
{
|
|
|
|
return $user->hasPermission('role.view');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function create(User $user): bool
|
|
|
|
{
|
|
|
|
return $user->hasPermission('role.create');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function update(User $user, Role $role): bool
|
|
|
|
{
|
|
|
|
return $user->hasPermission('role.update');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function delete(User $user, Role $role): bool
|
|
|
|
{
|
2023-08-01 22:07:47 +06:00
|
|
|
return $user->hasPermission('role.delete');
|
2023-07-16 19:21:09 +06:00
|
|
|
}
|
|
|
|
}
|