Laravel : How to redirect back to previous page after login

{ // deep_execution_view
const authorName = "Ankit Agrawal";
//
const publishDate = "June 17, 2019";

laravel is free open source php framework.it is a very powerful tool to create large and robust web applications. It follows the MVC structure

Use below code to redirect back to previous page after login

Update your LoginController.php

use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\URL;

public function __construct()
{
    $this->middleware('guest', ['except' => 'logout']);
    Session::put('preUrl', URL::previous());
}


public function redirectTo()
{
    return Session::get('preUrl') ? Session::get('preUrl') :   $this->redirectTo;
}


}