Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
RedirectIfAuthenticated
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
20
0.00% covered (danger)
0.00%
0 / 1
 handle
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
20
1<?php
2
3namespace App\Http\Middleware;
4
5use App\Providers\RouteServiceProvider;
6use Closure;
7use Illuminate\Http\Request;
8use Illuminate\Support\Facades\Auth;
9
10class 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}