Description
I am using spatie permssion package and created resource controller for Permission CRUD, only destroy() metohd is not working and giving error at $permission->delete();
View Code
use Spatie\Permission\Models\Permission;
public function destroy(Permission $permission): RedirectResponse
{
$permission->delete();
return to_route('permissions.index')->with('message', 'Permission deleted successfully');
}
In spatie if you want to delete the assign role, you need to call the revoke method to unlink the permission rather than deleting the permission itself.
How to do that:
~~~
$role->revokePermissionTo($permission);
~~~
Then this permission will be unlinked from the user or role.
0 Likes 0 Comments