Created
June 18, 2018 06:56
-
-
Save jinoantony/8d9dfaae199242fbccdd99f65110cfa7 to your computer and use it in GitHub Desktop.
RedirectIfAuthenticated Middleware
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Middleware; | |
use Closure; | |
use Illuminate\Support\Facades\Auth; | |
class RedirectIfAuthenticated | |
{ | |
/** | |
* Handle an incoming request. | |
* | |
* @param \Illuminate\Http\Request $request | |
* @param \Closure $next | |
* @param string|null $guard | |
* @param string $redirectTo | |
* @return mixed | |
*/ | |
public function handle($request, Closure $next, $guard = null, $redirectTo = '/home') | |
{ | |
if (Auth::guard($guard)->check()) { | |
return redirect($redirectTo); | |
} | |
return $next($request); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment