ldc-legaulois/app/Policies/Rules/UserStaticRules.php

40 lines
697 B
PHP
Raw Permalink Normal View History

2024-01-10 14:49:46 +01:00
<?php
namespace App\Policies\Rules;
use App\Enums\Users\RoleEnum;
use Illuminate\Database\Eloquent\Model;
2024-01-10 14:49:46 +01:00
/**
* Userlevel Policiy Static Rules
*
* @codeCoverageIgnore
*/
abstract class UserStaticRules
{
/**
* Allow everyone.
*/
public static function everyOne(): bool
{
return true;
}
/**
* Allow no one.
*/
public static function noOne(): bool
{
return false;
}
/**
* At least a minimum role
*/
public static function atLeastRole(Model $authModel, RoleEnum $minRole): bool
2024-01-10 14:49:46 +01:00
{
// phpcs:enable
return isset($authModel->role) && $authModel->role->value() <= $minRole->value();
2024-01-10 14:49:46 +01:00
}
}