110 lines
2.9 KiB
PHP
110 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace App\Policies;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Uwil\LaravelBackend\Enums\RoleEnum;
|
|
use Uwil\LaravelBackend\Policies\Rules\UserStaticRules;
|
|
|
|
class DocumentCategoryPolicy
|
|
{
|
|
/**
|
|
* 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 trash models.
|
|
*
|
|
* @param \Illuminate\Database\Eloquent\Model $authModel
|
|
* @return boolean
|
|
*/
|
|
public function viewTrash(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 duplicate the model.
|
|
*
|
|
* @param \Illuminate\Database\Eloquent\Model $authModel
|
|
* @return boolean
|
|
*/
|
|
public function duplicate(Model $authModel): bool
|
|
{
|
|
// TODO: duplicate wysiwyg path image.
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* 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, 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 force delete the model.
|
|
*
|
|
* @param \Illuminate\Database\Eloquent\Model $authModel
|
|
* @return boolean
|
|
*/
|
|
public function forceDelete(Model $authModel): bool
|
|
{
|
|
return UserStaticRules::atLeastRole($authModel, RoleEnum::admin);
|
|
}
|
|
}
|