Conditions | 4 |
Paths | 5 |
Total Lines | 13 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
17 | public function handle($request, \Closure $next, $role) |
||
18 | { |
||
19 | if (! $request->user()) { |
||
20 | return redirect(route('login')); |
||
21 | } |
||
22 | |||
23 | $roles = is_string($role) ? explode('|', $role) : $role; |
||
|
|||
24 | |||
25 | if (! $request->user()->hasAnyRole($roles)) { |
||
26 | abort(Response::HTTP_FORBIDDEN, 'You do not have the permission.'); |
||
27 | } |
||
28 | |||
29 | return $next($request); |
||
30 | } |
||
32 |