Added and updated policy
This commit is contained in:
79
app/Policies/RolePolicy.php
Normal file
79
app/Policies/RolePolicy.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
// use App\Models\SpatiePermissionModelsRole;
|
||||
use App\Models\User;
|
||||
use Spatie\Permission\Models\Role;
|
||||
use Illuminate\Auth\Access\Response;
|
||||
|
||||
class RolePolicy
|
||||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->hasPermissionTo('view roles');
|
||||
// return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, Role $role): bool // Changed typehint
|
||||
// public function view(User $user, SpatiePermissionModelsRole $spatiePermissionModelsRole): bool
|
||||
{
|
||||
return $user->hasPermissionTo('view roles');
|
||||
// return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->hasPermissionTo('create roles');
|
||||
// return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*/
|
||||
public function update(User $user, Role $role): bool // Changed typehint
|
||||
// public function update(User $user, SpatiePermissionModelsRole $spatiePermissionModelsRole): bool
|
||||
{
|
||||
return $user->hasPermissionTo('edit roles');
|
||||
// return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*/
|
||||
public function delete(User $user, Role $role): bool // Changed typehint
|
||||
// public function delete(User $user, SpatiePermissionModelsRole $spatiePermissionModelsRole): bool
|
||||
{
|
||||
return $user->hasPermissionTo('delete roles');
|
||||
// return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can restore the model.
|
||||
*/
|
||||
public function restore(User $user, Role $role): bool // Changed typehint
|
||||
// public function restore(User $user, SpatiePermissionModelsRole $spatiePermissionModelsRole): bool
|
||||
{
|
||||
return $user->hasPermissionTo('restore roles');
|
||||
// return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can permanently delete the model.
|
||||
*/
|
||||
// public function forceDelete(User $user, SpatiePermissionModelsRole $spatiePermissionModelsRole): bool
|
||||
public function forceDelete(User $user, Role $role): bool // Changed typehint
|
||||
{
|
||||
return $user->hasPermissionTo('force-delete roles');
|
||||
// return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user