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