diff --git a/src/Role.php b/src/Role.php index fc1fcf9..f52a0e0 100644 --- a/src/Role.php +++ b/src/Role.php @@ -52,9 +52,11 @@ public function setPermissions(array $permissions) $this->revokeAll(); - collect($permissions)->map(function ($permission) { + collect($permissions)->each(function ($permission) { $this->grant($permission); }); + + $this->setRelations([]); } /** @@ -90,8 +92,6 @@ public function grant($permission) 'role_id' => $this->id, 'permission_slug' => $permission, ]); - - return false; } /** @@ -103,8 +103,12 @@ public function grant($permission) */ public function revoke($permission) { - if (\is_string($permission)) { - return Permission::findOrFail($permission)->delete(); + if (\is_string($permission)) { + Permission::findOrFail($permission)->delete(); + + $this->setRelations([]); + + return true; } return false; @@ -115,7 +119,11 @@ public function revoke($permission) */ public function revokeAll() { - return $this->getPermissions()->delete(); + $this->getPermissions()->delete(); + + $this->setRelations([]); + + return true; } /**