| @@ 170-181 (lines=12) @@ | ||
| 167 | * @return bool |
|
| 168 | * @throws \Exception |
|
| 169 | */ |
|
| 170 | public function hasAnyPermission(...$permissions): bool |
|
| 171 | { |
|
| 172 | $permissions = collect($permissions)->flatten(); |
|
| 173 | ||
| 174 | foreach ($permissions as $permission) { |
|
| 175 | if ($this->checkPermissionTo($permission)) { |
|
| 176 | return true; |
|
| 177 | } |
|
| 178 | } |
|
| 179 | ||
| 180 | return false; |
|
| 181 | } |
|
| 182 | ||
| 183 | /** |
|
| 184 | * Determine if the model has all of the given permissions. |
|
| @@ 191-202 (lines=12) @@ | ||
| 188 | * @return bool |
|
| 189 | * @throws \Exception |
|
| 190 | */ |
|
| 191 | public function hasAllPermissions(...$permissions): bool |
|
| 192 | { |
|
| 193 | $permissions = collect($permissions)->flatten(); |
|
| 194 | ||
| 195 | foreach ($permissions as $permission) { |
|
| 196 | if (! $this->hasPermissionTo($permission)) { |
|
| 197 | return false; |
|
| 198 | } |
|
| 199 | } |
|
| 200 | ||
| 201 | return true; |
|
| 202 | } |
|
| 203 | ||
| 204 | /** |
|
| 205 | * Determine if the model has, via roles, the given permission. |
|
| @@ 421-432 (lines=12) @@ | ||
| 418 | * @param array ...$permissions |
|
| 419 | * @return bool |
|
| 420 | */ |
|
| 421 | public function hasAllDirectPermissions(...$permissions): bool |
|
| 422 | { |
|
| 423 | $permissions = collect($permissions)->flatten(); |
|
| 424 | ||
| 425 | foreach ($permissions as $permission) { |
|
| 426 | if (! $this->hasDirectPermission($permission)) { |
|
| 427 | return false; |
|
| 428 | } |
|
| 429 | } |
|
| 430 | ||
| 431 | return true; |
|
| 432 | } |
|
| 433 | ||
| 434 | /** |
|
| 435 | * Check if the model has Any of the requested Direct permissions. |
|
| @@ 439-450 (lines=12) @@ | ||
| 436 | * @param array ...$permissions |
|
| 437 | * @return bool |
|
| 438 | */ |
|
| 439 | public function hasAnyDirectPermission(...$permissions): bool |
|
| 440 | { |
|
| 441 | $permissions = collect($permissions)->flatten(); |
|
| 442 | ||
| 443 | foreach ($permissions as $permission) { |
|
| 444 | if ($this->hasDirectPermission($permission)) { |
|
| 445 | return true; |
|
| 446 | } |
|
| 447 | } |
|
| 448 | ||
| 449 | return false; |
|
| 450 | } |
|
| 451 | } |
|
| 452 | ||