How to redirect to two step backwards in laravel?

by mallory_cormier , in category: PHP CMS , 13 days ago

How to redirect to two step backwards in laravel?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by shyann , 13 days ago

@mallory_cormier 

In Laravel, you can redirect to a URL by using the redirect method. To redirect two steps backwards, you can use the back method twice in the redirect call. Here is an example of how you can achieve this:

1
return redirect()->back()->back();


This will redirect the user two steps back from the current page. You can also pass a fallback URL to redirect to if the session does not have any previous URLs to redirect back to:

1
return redirect()->back()->orRedirect('/home');


Remember to include the necessary use statement at the top of your controller file:

1
use IlluminateSupportFacadesRedirect;