@@ 215-226 (lines=12) @@ | ||
212 | * @return bool |
|
213 | * @throws \Exception |
|
214 | */ |
|
215 | public function hasAnyPermission(...$permissions): bool |
|
216 | { |
|
217 | $permissions = collect($permissions)->flatten(); |
|
218 | ||
219 | foreach ($permissions as $permission) { |
|
220 | if ($this->checkPermissionTo($permission)) { |
|
221 | return true; |
|
222 | } |
|
223 | } |
|
224 | ||
225 | return false; |
|
226 | } |
|
227 | ||
228 | /** |
|
229 | * Determine if the model has all of the given permissions. |
|
@@ 236-247 (lines=12) @@ | ||
233 | * @return bool |
|
234 | * @throws \Exception |
|
235 | */ |
|
236 | public function hasAllPermissions(...$permissions): bool |
|
237 | { |
|
238 | $permissions = collect($permissions)->flatten(); |
|
239 | ||
240 | foreach ($permissions as $permission) { |
|
241 | if (! $this->hasPermissionTo($permission)) { |
|
242 | return false; |
|
243 | } |
|
244 | } |
|
245 | ||
246 | return true; |
|
247 | } |
|
248 | ||
249 | /** |
|
250 | * Determine if the model has, via roles, the given permission. |
|
@@ 466-477 (lines=12) @@ | ||
463 | * @param array ...$permissions |
|
464 | * @return bool |
|
465 | */ |
|
466 | public function hasAllDirectPermissions(...$permissions): bool |
|
467 | { |
|
468 | $permissions = collect($permissions)->flatten(); |
|
469 | ||
470 | foreach ($permissions as $permission) { |
|
471 | if (! $this->hasDirectPermission($permission)) { |
|
472 | return false; |
|
473 | } |
|
474 | } |
|
475 | ||
476 | return true; |
|
477 | } |
|
478 | ||
479 | /** |
|
480 | * Check if the model has Any of the requested Direct permissions. |
|
@@ 484-495 (lines=12) @@ | ||
481 | * @param array ...$permissions |
|
482 | * @return bool |
|
483 | */ |
|
484 | public function hasAnyDirectPermission(...$permissions): bool |
|
485 | { |
|
486 | $permissions = collect($permissions)->flatten(); |
|
487 | ||
488 | foreach ($permissions as $permission) { |
|
489 | if ($this->hasDirectPermission($permission)) { |
|
490 | return true; |
|
491 | } |
|
492 | } |
|
493 | ||
494 | return false; |
|
495 | } |
|
496 | } |
|
497 |