2

I need someway to redirect my app to a previous url.

The problem comes when i make a submit that goes wrong, the redirect->back previous url is someway "overwrited" and i cannot get the previous real url anymore, instead the app makes the submit again.

The only thing that i tried is the redirect back, because i can't find another way to do it :S

So i´m wondering if there is a way to achieve that, redirect the app to a previous url without considering the submit fails and all this stuff.

Thank you.

Youcef LAIDANI
  • 55,661
  • 15
  • 90
  • 140
Sampudon
  • 85
  • 1
  • 8

2 Answers2

0

Yo can try with:

  return Redirect::to(URL::previous());
Ferran
  • 142
  • 1
  • 10
0

You can store URLs in session and then make Laravel redirect 2 or 3 pages back. Simple example of code to store URL in session:

$links = session->has('links') ? session('links') : []; // Get data from session
array_unshift($links, $_SERVER['REQUEST_URI']); // Add current URI to an array
session(compact('links')); // Save an array to session

And example of code for redirecting:

return redirect(session('links')[2]);
Community
  • 1
  • 1
Alexey Mezenin
  • 158,981
  • 26
  • 290
  • 279