Interactive Books' Atelier's blog

How are you?

Redirect to intended destination after login

7 months ago |

In /app/Http/Middleware/RedirectIfAuthenticated.php change the handle function slightly:

    public function handle($request, Closure $next, $guard = null)
        if (Auth::guard($guard)->check()) {
            return redirect()->intended('/home');


Default is return redirect("/home");

Since Laravel >= 5.3 automatically saves the last "intended" route when checking the Auth Guard, it changes to:

    return redirect()->intended('/home');

That tells Laravel to redirect to the last intended page before login, otherwise go to "/home" or wherever you'd like to send them by default.


By Scott Byers