ldc-crm/app/Policies/ServicePolicy.php

65 lines
1.3 KiB
PHP
Raw Permalink Normal View History

2023-06-20 17:37:15 +02:00
<?php
namespace App\Policies;
use App\Enums\Users\RoleEnum;
use App\Models\User;
use App\Policies\Rules\UserStaticRules;
2023-06-20 17:37:15 +02:00
class ServicePolicy
{
/**
* View an Answer.
*
* @param \App\Models\User $authUser
2023-06-20 17:37:15 +02:00
* @return boolean
*/
public function view(User $authUser): bool
2023-06-20 17:37:15 +02:00
{
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
2023-06-20 17:37:15 +02:00
}
/**
* ViewAny an Service.
2023-06-20 17:37:15 +02:00
*
* @param \App\Models\User $authUser
2023-06-20 17:37:15 +02:00
* @return boolean
*/
public function viewAny(User $authUser): bool
2023-06-20 17:37:15 +02:00
{
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
2023-06-20 17:37:15 +02:00
}
/**
* Create an Service.
*
* @param \App\Models\User $authUser
2023-06-20 17:37:15 +02:00
* @return boolean
*/
public function create(User $authUser): bool
2023-06-20 17:37:15 +02:00
{
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
2023-06-20 17:37:15 +02:00
}
/**
* Update an Service.
*
* @param \App\Models\User $authUser
2023-06-20 17:37:15 +02:00
* @return boolean
*/
public function update(User $authUser): bool
2023-06-20 17:37:15 +02:00
{
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
2023-06-20 17:37:15 +02:00
}
/**
* Delete an Service.
*
* @return boolean
*/
public function delete(): bool
{
return UserStaticRules::noOne();
2023-06-20 17:37:15 +02:00
}
}