Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
RedirectIfAuthenticated | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
20 | |
0.00% |
0 / 1 |
handle | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
20 |
1 | <?php |
2 | |
3 | namespace App\Http\Middleware; |
4 | |
5 | use App\Providers\RouteServiceProvider; |
6 | use Closure; |
7 | use Illuminate\Http\Request; |
8 | use Illuminate\Support\Facades\Auth; |
9 | |
10 | class RedirectIfAuthenticated |
11 | { |
12 | /** |
13 | * Handle an incoming request. |
14 | * |
15 | * @param \Illuminate\Http\Request $request |
16 | * @param \Closure $next |
17 | * @param string|null ...$guards |
18 | * @return mixed |
19 | */ |
20 | public function handle(Request $request, Closure $next, ...$guards) |
21 | { |
22 | $guards = empty($guards) ? [null] : $guards; |
23 | |
24 | foreach ($guards as $guard) { |
25 | if (Auth::guard($guard)->check()) { |
26 | return redirect(RouteServiceProvider::HOME); |
27 | } |
28 | } |
29 | |
30 | return $next($request); |
31 | } |
32 | } |