77 lines
1.7 KiB
PHP
77 lines
1.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Policies;
|
|
|
|
use Illuminate\Foundation\Auth\User as AuthUser;
|
|
use App\Models\Page;
|
|
use Illuminate\Auth\Access\HandlesAuthorization;
|
|
|
|
class PagePolicy
|
|
{
|
|
use HandlesAuthorization;
|
|
|
|
public function before(AuthUser $user, $ability)
|
|
{
|
|
if ($user->hasRole('super_admin')) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
public function viewAny(AuthUser $authUser): bool
|
|
{
|
|
return $authUser->can('ViewAny:Page');
|
|
}
|
|
|
|
public function view(AuthUser $authUser, Page $page): bool
|
|
{
|
|
return $authUser->can('View:Page');
|
|
}
|
|
|
|
public function create(AuthUser $authUser): bool
|
|
{
|
|
return $authUser->can('Create:Page');
|
|
}
|
|
|
|
public function update(AuthUser $authUser, Page $page): bool
|
|
{
|
|
return $authUser->can('Update:Page');
|
|
}
|
|
|
|
public function delete(AuthUser $authUser, Page $page): bool
|
|
{
|
|
return $authUser->can('Delete:Page');
|
|
}
|
|
|
|
public function restore(AuthUser $authUser, Page $page): bool
|
|
{
|
|
return $authUser->can('Restore:Page');
|
|
}
|
|
|
|
public function forceDelete(AuthUser $authUser, Page $page): bool
|
|
{
|
|
return $authUser->can('ForceDelete:Page');
|
|
}
|
|
|
|
public function forceDeleteAny(AuthUser $authUser): bool
|
|
{
|
|
return $authUser->can('ForceDeleteAny:Page');
|
|
}
|
|
|
|
public function restoreAny(AuthUser $authUser): bool
|
|
{
|
|
return $authUser->can('RestoreAny:Page');
|
|
}
|
|
|
|
public function replicate(AuthUser $authUser, Page $page): bool
|
|
{
|
|
return $authUser->can('Replicate:Page');
|
|
}
|
|
|
|
public function reorder(AuthUser $authUser): bool
|
|
{
|
|
return $authUser->can('Reorder:Page');
|
|
}
|
|
|
|
} |