Skip to content

Commit

Permalink
revokePermissionTo, removeRole works with trait collects method
Browse files Browse the repository at this point in the history
  • Loading branch information
erikn69 committed Nov 13, 2023
1 parent b3f23d4 commit 6549e41
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
5 changes: 1 addition & 4 deletions src/Traits/HasPermissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -452,10 +452,7 @@ public function syncPermissions(...$permissions)
*/
public function revokePermissionTo($permission)
{
$this->permissions()->detach(array_map(
fn ($item) => $this->getStoredPermission($item)->getKey(),
is_a($permission, Collection::class) ? $permission->all() : Arr::wrap($permission)
));
$this->permissions()->detach($this->collectPermissions($permission));

if (is_a($this, Role::class)) {
$this->forgetCachedPermissions();
Expand Down
5 changes: 1 addition & 4 deletions src/Traits/HasRoles.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,7 @@ function ($object) use ($roles, $model, $teamPivot) {
*/
public function removeRole($role)
{
$this->roles()->detach(array_map(
fn ($item) => $this->getStoredRole($item)->getKey(),
is_a($role, Collection::class) ? $role->all() : Arr::wrap($role)
));
$this->roles()->detach($this->collectRoles($role));

$this->unsetRelation('roles');

Expand Down

0 comments on commit 6549e41

Please sign in to comment.