106 lines
3.3 KiB
PHP
106 lines
3.3 KiB
PHP
<?php
|
|
|
|
namespace App\Policies;
|
|
|
|
use App\Enums\Users\RoleEnum;
|
|
use App\Models\GeneralSetting;
|
|
use App\Models\User;
|
|
use App\Policies\Rules\UserStaticRules;
|
|
use Illuminate\Auth\Access\Response;
|
|
|
|
class GeneralSettingPolicy
|
|
{
|
|
/**
|
|
* Determine whether the user can view any models.
|
|
*
|
|
* @param \App\Models\User $authUser
|
|
* @return boolean
|
|
*/
|
|
public function viewAny(User $authUser): bool
|
|
{
|
|
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can view the model.
|
|
*
|
|
* @param \App\Models\User $authUser
|
|
* @param \App\Models\GeneralSetting $generalSetting
|
|
* @return boolean
|
|
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed
|
|
*/
|
|
public function view(User $authUser, GeneralSetting $generalSetting): bool
|
|
{
|
|
// phpcs:enable
|
|
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can create models.
|
|
*
|
|
* @param \App\Models\User $authUser
|
|
* @return \Illuminate\Auth\Access\Response
|
|
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.Found
|
|
*/
|
|
public function create(User $authUser): Response
|
|
{
|
|
// phpcs:enable
|
|
return Response::deny('Creating a setting is not allowed');
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can update the model.
|
|
*
|
|
* @param \App\Models\User $authUser
|
|
* @param \App\Models\GeneralSetting $generalSetting
|
|
* @return boolean
|
|
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed
|
|
*/
|
|
public function update(User $authUser, GeneralSetting $generalSetting): bool
|
|
{
|
|
// phpcs:enable
|
|
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can delete the model.
|
|
*
|
|
* @param \App\Models\User $authUser
|
|
* @param \App\Models\GeneralSetting $generalSetting
|
|
* @return \Illuminate\Auth\Access\Response
|
|
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed
|
|
*/
|
|
public function delete(User $authUser, GeneralSetting $generalSetting): Response
|
|
{
|
|
// phpcs:enable
|
|
return Response::deny('Deleting a setting is not allowed');
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can delete the model.
|
|
*
|
|
* @param \App\Models\User $authUser
|
|
* @param \App\Models\GeneralSetting $generalSetting
|
|
* @return \Illuminate\Auth\Access\Response
|
|
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed
|
|
*/
|
|
public function restore(User $authUser, GeneralSetting $generalSetting): Response
|
|
{
|
|
// phpcs:enable
|
|
return Response::deny('Deleting a setting is not allowed');
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can delete the model.
|
|
*
|
|
* @param \App\Models\User $authUser
|
|
* @param \App\Models\GeneralSetting $generalSetting
|
|
* @return \Illuminate\Auth\Access\Response
|
|
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed
|
|
*/
|
|
public function forceDelete(User $authUser, GeneralSetting $generalSetting): Response
|
|
{
|
|
// phpcs:enable
|
|
return Response::deny('Deleting a setting is not allowed');
|
|
}
|
|
}
|