| Conditions | 5 |
| Paths | 7 |
| Total Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | public function handle($request, Closure $next, $permission, $guard = null) |
||
| 11 | { |
||
| 12 | if (app('auth')->guard($guard)->guest()) { |
||
| 13 | throw UnauthorizedException::notLoggedIn(); |
||
| 14 | } |
||
| 15 | |||
| 16 | $permissions = is_array($permission) |
||
| 17 | ? $permission |
||
| 18 | : explode('|', $permission); |
||
| 19 | |||
| 20 | foreach ($permissions as $permission) { |
||
| 21 | if (app('auth')->guard($guard)->user()->can($permission)) { |
||
| 22 | return $next($request); |
||
| 23 | } |
||
| 24 | } |
||
| 25 | |||
| 26 | throw UnauthorizedException::forPermissions($permissions); |
||
| 27 | } |
||
| 28 | } |
||
| 29 |