@@ 259-270 (lines=12) @@ | ||
256 | * @return bool |
|
257 | * @throws \Exception |
|
258 | */ |
|
259 | public function hasAnyPermission(...$permissions): bool |
|
260 | { |
|
261 | $permissions = collect($permissions)->flatten(); |
|
262 | ||
263 | foreach ($permissions as $permission) { |
|
264 | if ($this->checkPermissionTo($permission)) { |
|
265 | return true; |
|
266 | } |
|
267 | } |
|
268 | ||
269 | return false; |
|
270 | } |
|
271 | ||
272 | /** |
|
273 | * Determine if the model has all of the given permissions. |
|
@@ 280-291 (lines=12) @@ | ||
277 | * @return bool |
|
278 | * @throws \Exception |
|
279 | */ |
|
280 | public function hasAllPermissions(...$permissions): bool |
|
281 | { |
|
282 | $permissions = collect($permissions)->flatten(); |
|
283 | ||
284 | foreach ($permissions as $permission) { |
|
285 | if (!$this->hasPermissionTo($permission)) { |
|
286 | return false; |
|
287 | } |
|
288 | } |
|
289 | ||
290 | return true; |
|
291 | } |
|
292 | ||
293 | /** |
|
294 | * Determine if the model has, via roles, the given permission. |
|
@@ 510-521 (lines=12) @@ | ||
507 | * @param array ...$permissions |
|
508 | * @return bool |
|
509 | */ |
|
510 | public function hasAllDirectPermissions(...$permissions): bool |
|
511 | { |
|
512 | $permissions = collect($permissions)->flatten(); |
|
513 | ||
514 | foreach ($permissions as $permission) { |
|
515 | if (!$this->hasDirectPermission($permission)) { |
|
516 | return false; |
|
517 | } |
|
518 | } |
|
519 | ||
520 | return true; |
|
521 | } |
|
522 | ||
523 | /** |
|
524 | * Check if the model has Any of the requested Direct permissions. |
|
@@ 528-539 (lines=12) @@ | ||
525 | * @param array ...$permissions |
|
526 | * @return bool |
|
527 | */ |
|
528 | public function hasAnyDirectPermission(...$permissions): bool |
|
529 | { |
|
530 | $permissions = collect($permissions)->flatten(); |
|
531 | ||
532 | foreach ($permissions as $permission) { |
|
533 | if ($this->hasDirectPermission($permission)) { |
|
534 | return true; |
|
535 | } |
|
536 | } |
|
537 | ||
538 | return false; |
|
539 | } |
|
540 | } |
|
541 |