@@ 204-215 (lines=12) @@ | ||
201 | * @return bool |
|
202 | * @throws \Exception |
|
203 | */ |
|
204 | public function hasAnyPermission(...$permissions): bool |
|
205 | { |
|
206 | $permissions = collect($permissions)->flatten(); |
|
207 | ||
208 | foreach ($permissions as $permission) { |
|
209 | if ($this->checkPermissionTo($permission)) { |
|
210 | return true; |
|
211 | } |
|
212 | } |
|
213 | ||
214 | return false; |
|
215 | } |
|
216 | ||
217 | /** |
|
218 | * Determine if the model has all of the given permissions. |
|
@@ 225-236 (lines=12) @@ | ||
222 | * @return bool |
|
223 | * @throws \Exception |
|
224 | */ |
|
225 | public function hasAllPermissions(...$permissions): bool |
|
226 | { |
|
227 | $permissions = collect($permissions)->flatten(); |
|
228 | ||
229 | foreach ($permissions as $permission) { |
|
230 | if (! $this->hasPermissionTo($permission)) { |
|
231 | return false; |
|
232 | } |
|
233 | } |
|
234 | ||
235 | return true; |
|
236 | } |
|
237 | ||
238 | /** |
|
239 | * Determine if the model has, via roles, the given permission. |
|
@@ 455-466 (lines=12) @@ | ||
452 | * @param array ...$permissions |
|
453 | * @return bool |
|
454 | */ |
|
455 | public function hasAllDirectPermissions(...$permissions): bool |
|
456 | { |
|
457 | $permissions = collect($permissions)->flatten(); |
|
458 | ||
459 | foreach ($permissions as $permission) { |
|
460 | if (! $this->hasDirectPermission($permission)) { |
|
461 | return false; |
|
462 | } |
|
463 | } |
|
464 | ||
465 | return true; |
|
466 | } |
|
467 | ||
468 | /** |
|
469 | * Check if the model has Any of the requested Direct permissions. |
|
@@ 473-484 (lines=12) @@ | ||
470 | * @param array ...$permissions |
|
471 | * @return bool |
|
472 | */ |
|
473 | public function hasAnyDirectPermission(...$permissions): bool |
|
474 | { |
|
475 | $permissions = collect($permissions)->flatten(); |
|
476 | ||
477 | foreach ($permissions as $permission) { |
|
478 | if ($this->hasDirectPermission($permission)) { |
|
479 | return true; |
|
480 | } |
|
481 | } |
|
482 | ||
483 | return false; |
|
484 | } |
|
485 | } |
|
486 |