In Laravel, there is a function return back();
, which returns the user to the previous page. Is it possible to return back();
more than once within
it works for me Redirect::to($request->request->get('http_referrer'))
No, but you could use session system to save URLs of 2-3-4 pages back. Use Session::
facade or session()
helper for shorter syntax:
$links = session()->has('links') ? session('links') : [];
$currentLink = request()->path(); // Getting current URI like 'category/books/'
array_unshift($links, $currentLink); // Putting it in the beginning of links array
session(['links' => $links]); // Saving links array to the session
And to use it:
return redirect(session('links')[2]); // Will redirect 2 links back