E
E
Evgeny Perin2015-08-18 09:37:37
Laravel
Evgeny Perin, 2015-08-18 09:37:37

Redirect to previous page on login, laravel 5?

I can't figure out how to do this redirect. For example, a user is on the /abc page, and decided to log in / register, went to the /login page, entered the data and was redirected to the / page, but I would do it to redirect to /abc.
AuthController has a path for a redirect protected $redirectTo = '/' , but I didn't understand how to make it for a redirect back.
UPD
I read the documentation and know about the return back() redirect, but I can't figure out how to combine it with protected $redirectTo in AuthController

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
JhaoDa, 2015-08-18
@seoperin

The built-in authentication mechanism uses the RedirectsUsers trait, which has a redirectPath() method. Redefine it in your controller and return what you need:

public function redirectPath()
{
    return back();
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question