112 lines
3.2 KiB
PHP
112 lines
3.2 KiB
PHP
<?php
|
|
|
|
namespace App\Policies;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Uwil\LaravelBackend\Policies\Rules\UserStaticRules;
|
|
use Uwil\LaravelBackend\Support\UserRoleRegistry;
|
|
|
|
/**
|
|
* Handles authorization for InvoicePackage model actions.
|
|
*/
|
|
class InvoicePackagePolicy
|
|
{
|
|
/**
|
|
* 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, UserRoleRegistry::get('developper')->value);
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can view trash models.
|
|
*
|
|
* @param \Illuminate\Database\Eloquent\Model $authModel
|
|
* @return boolean
|
|
*/
|
|
public function viewTrash(Model $authModel): bool
|
|
{
|
|
return UserStaticRules::atLeastRole($authModel, UserRoleRegistry::get('developper')->value);
|
|
}
|
|
|
|
/**
|
|
* 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, UserRoleRegistry::get('developper')->value);
|
|
}
|
|
|
|
/**
|
|
* 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, UserRoleRegistry::get('developper')->value);
|
|
}
|
|
|
|
/**
|
|
* 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, UserRoleRegistry::get('developper')->value);
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can duplicate the model.
|
|
*
|
|
* @param \Illuminate\Database\Eloquent\Model $authModel
|
|
* @return boolean
|
|
*/
|
|
public function duplicate(Model $authModel): bool
|
|
{
|
|
return UserStaticRules::atLeastRole($authModel, UserRoleRegistry::get('developper')->value);
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can restore the model.
|
|
*
|
|
* @param \Illuminate\Database\Eloquent\Model $authModel
|
|
* @return boolean
|
|
*/
|
|
public function restore(Model $authModel): bool
|
|
{
|
|
return UserStaticRules::atLeastRole($authModel, UserRoleRegistry::get('developper')->value);
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can soft delete the model.
|
|
*
|
|
* @param \Illuminate\Database\Eloquent\Model $authModel
|
|
* @return boolean
|
|
*/
|
|
public function delete(Model $authModel): bool
|
|
{
|
|
return UserStaticRules::atLeastRole($authModel, UserRoleRegistry::get('developper')->value);
|
|
}
|
|
|
|
/**
|
|
* Determine whether the user can permanently delete the model.
|
|
*
|
|
* @param \Illuminate\Database\Eloquent\Model $authModel
|
|
* @return boolean
|
|
*/
|
|
public function forceDelete(Model $authModel): bool
|
|
{
|
|
return UserStaticRules::atLeastRole($authModel, UserRoleRegistry::get('developper')->value);
|
|
}
|
|
}
|