In this tutorial, we will learn how to redirect back to previous page or URL after successful login in laravel application.


Below are two method to do: 


Method 1 : 

Open LoginController and add ShowLoginForm method.  


app/Http/Controllers/Auth/LoginController.php

public function showLoginForm()
{
    if(!session()->has('url.intended'))
    {
        session(['url.intended' => url()->previous()]);
    }
    return view('auth.login');
}



Method 2 :

add __contruct() method to redirect previous url or page inside LoginController. 


app/Http/Controllers/Auth/LoginController.php

public function __construct()
{
    $this->middleware('guest')->except('logout');
    $this->redirectTo = url()->previous();
}


I hope this example helps you.