From a1e4463d7a074565182915f472b10445d18c93e2 Mon Sep 17 00:00:00 2001 From: Mohammad ALTAWEEL Date: Fri, 18 Nov 2022 07:45:37 +0800 Subject: [PATCH] Don't throw an exception when checking permission --- src/Traits/HasPermissions.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Traits/HasPermissions.php b/src/Traits/HasPermissions.php index 7e89ec7a2..d55450bfc 100644 --- a/src/Traits/HasPermissions.php +++ b/src/Traits/HasPermissions.php @@ -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; } } @@ -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 */ @@ -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 */