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