Reputation: 21
I have an form on an edit screen and on submit I want to redirect back two pages.
Is there a way to do this in Laravel? I haven't been able to find anything online.
Thanks!
Upvotes: 2
Views: 3535
Reputation: 8849
Laravel redirects back using either the Referer
HTTP header or an internal session key _previous.url
which changes on every request. So there is nothing in Laravel that specifically redirects back two pages.
As @kerbholz mentioned you could simply redirect to the correct page.
If you can't do that you could manually store the URL to redirect to in the session on the page you want to redirect to:
session(['previous-url' => request()->url());
And redirect after the form is submitted:
return redirect(session('previous-url'));
Upvotes: 6