<?php namespace App\Http\Middleware; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use App\Providers\RouteServiceProvider; class RedirectIfAuthenticated { /** * Handle an incoming request. * * @param Request $request * @param \Closure $next * @param string|null $guard * @return mixed */ public function handle(Request $request,\Closure $next,?string $guard=NULL) { if (Auth::guard($guard)->check()) { return redirect(RouteServiceProvider::HOME); } return $next($request); } }