File: D:/HostingSpaces/SBogers10/farmfun.komma.pro/app/Komma/Pages/PagePolicy.php
<?php
namespace App\Komma\Pages;
use App\Komma\Base\Policy;
use App\Komma\Pages\Models\Page;
use App\Komma\Users\Models\KmsUser;
use App\Komma\Users\Models\KmsUserRole;
use Illuminate\Auth\Access\HandlesAuthorization;
final class PagePolicy extends Policy
{
use HandlesAuthorization;
protected $modelClassName = Page::class;
/**
* Create a new policy instance.
*
* @return void
*/
public function __construct()
{
// parent::$DEBUG = PagePolicy::class;
}
/**
* Determine if it is allowed to show a form for creating a new resource
*
* @param KmsUser|null $user
* @return bool
*/
public function create(KmsUser $user): bool
{
$result = $user->isAtLeast(KmsUserRole::Admin);
$this->debug('create', $result);
return $result;
}
/**
* Determine if it is allowed to destroy an existing resource
*
* @param KmsUser|null $user
* @return bool
*/
public function destroy(KmsUser $user, $modelToDestroy): bool
{
$result = $user->isAtLeast(KmsUserRole::Admin) && (substr($modelToDestroy->code_name, 0, 5) === 'page_');
$this->debug('destroy', $result);
return $result;
}
}