ldc-dam/app/Policies/UserPolicy.php
2026-06-04 17:17:38 +02:00

76 lines
2 KiB
PHP

<?php
namespace App\Policies;
use App\Enums\Users\RoleEnum;
use App\Policies\Rules\UserStaticRules;
use Illuminate\Database\Eloquent\Model;
class UserPolicy
{
/**
* Determine whether the user can view any models.
*
* @param \Illuminate\Database\Eloquent\Model $authModel
* @return boolean
*/
public function viewAny(Model $authModel): bool
{
return UserStaticRules::atLeastRole($authModel, RoleEnum::admin);
}
/**
* Determine whether the user can view the model.
*
* @param \Illuminate\Database\Eloquent\Model $authModel
* @return boolean
*/
public function view(Model $authModel): bool
{
return UserStaticRules::atLeastRole($authModel, RoleEnum::admin);
}
/**
* Determine whether the user can create models.
*
* @param \Illuminate\Database\Eloquent\Model $authModel
* @return boolean
*/
public function create(Model $authModel): bool
{
return UserStaticRules::atLeastRole($authModel, RoleEnum::admin);
}
/**
* Determine whether the user can update the model.
*
* @param \Illuminate\Database\Eloquent\Model $authModel
* @return boolean
*/
public function update(Model $authModel): bool
{
return UserStaticRules::atLeastRole($authModel, RoleEnum::admin);
}
/**
* Determine whether the user can delete the model.
*
* @param \Illuminate\Database\Eloquent\Model $authModel
* @return boolean
*/
public function delete(Model $authModel): bool
{
return UserStaticRules::atLeastRole($authModel, RoleEnum::admin);
}
/**
* Determine whether the user can get datas with an employee registration number in user creation form.
*
* @param \Illuminate\Database\Eloquent\Model $authModel
* @return boolean
*/
public function checkMatricule(Model $authModel): bool
{
return UserStaticRules::atLeastRole($authModel, RoleEnum::admin);
}
}