Laravel : How to redirect back to previous page after login

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;
}