Go to your loginContorller and open it. Then add this showLoginForm()
function code as follow:
public function showLoginForm()
{
if(!session()->has('url.intended'))
{
session(['url.intended' => url()->previous()]);
}
return view('auth.login');
}
This function will set the “url.intended” session variable. Laravel uses this variable to look for the page in which the user will be redirected after login.
In second method, you can add the following code into the add this line to the __construct()
function inside LoginController as follow:
$this->redirectTo = url()->previous();
As follow:
public function __construct()
{
$this->middleware('guest')->except('logout');
$this->redirectTo = url()->previous();
}
#laravel