| Conditions | 4 |
| Paths | 4 |
| Total Lines | 22 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 20 | public function handle($request, Closure $next, $role, $needsAll = false) |
||
| 21 | { |
||
| 22 | /* |
||
| 23 | * Roles array |
||
| 24 | */ |
||
| 25 | if (strpos($role, ';') !== false) { |
||
| 26 | $roles = explode(';', $role); |
||
| 27 | $access = access()->hasRoles($roles, ($needsAll === 'true' ? true : false)); |
||
| 28 | } else { |
||
| 29 | /** |
||
| 30 | * Single role. |
||
| 31 | */ |
||
| 32 | $access = access()->hasRole($role); |
||
| 33 | } |
||
| 34 | |||
| 35 | if (! $access) { |
||
| 36 | return redirect() |
||
| 37 | ->route(homeRoute()) |
||
| 38 | ->withFlashDanger(trans('backpack::crud.unauthorized_access')); |
||
| 39 | } |
||
| 40 | |||
| 41 | return $next($request); |
||
| 42 | } |
||
| 44 |