C
C
cryp242019-06-15 04:06:11
Laravel
cryp24, 2019-06-15 04:06:11

Laravel how to redirect to previous page?

laravel standard login. How to make it so that when going to the authorization page, remember request()->server('HTTP_REFERER') and pass the variable to

protected function redirectTo()
{
    return url( переменная );
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
cryp24, 2019-06-15
@cryp24

The question was solved as follows:
For authorization:
In the login form template, add
Add to LoginController

protected function redirectTo(){
        return url($_REQUEST['httpref']);
    }

To exit:
In the exit form template, add
In LoginController by connecting (use Illuminate\Http\Request;) we replace "use AuthenticatesUsers" with
use AuthenticatesUsers {
        logout as performLogout;
    }
    public function logout(Request $request)
    {
        $this->performLogout($request);
        return redirect($_SERVER['HTTP_REFERER']);
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question