Skip to content

Commit

Permalink
Merge pull request #2248 from mtawil/patch-1
Browse files Browse the repository at this point in the history
Don't throw an exception when checking hasAllPermissions()
  • Loading branch information
drbyte authored Nov 19, 2022
2 parents ddaeda1 + a1e4463 commit 76dd153
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Traits/HasPermissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,13 @@ public function hasAnyPermission(...$permissions): bool
* @param string|int|array|\Spatie\Permission\Contracts\Permission|\Illuminate\Support\Collection ...$permissions
*
* @return bool
* @throws \Exception
*/
public function hasAllPermissions(...$permissions): bool
{
$permissions = collect($permissions)->flatten();

foreach ($permissions as $permission) {
if (! $this->hasPermissionTo($permission)) {
if (! $this->checkPermissionTo($permission)) {
return false;
}
}
Expand Down Expand Up @@ -486,6 +485,7 @@ public function forgetCachedPermissions()

/**
* Check if the model has All of the requested Direct permissions.
*
* @param string|int|array|\Spatie\Permission\Contracts\Permission|\Illuminate\Support\Collection ...$permissions
* @return bool
*/
Expand All @@ -504,6 +504,7 @@ public function hasAllDirectPermissions(...$permissions): bool

/**
* Check if the model has Any of the requested Direct permissions.
*
* @param string|int|array|\Spatie\Permission\Contracts\Permission|\Illuminate\Support\Collection ...$permissions
* @return bool
*/
Expand Down

0 comments on commit 76dd153

Please sign in to comment.