W3docs

Laravel back button

In Laravel, you can use the back function to redirect the user to their previous page.

In Laravel, you can use the back function to redirect the user to their previous page. This is equivalent to calling the redirect function with no parameters.

Example:

Example of using the back() function to redirect the user to their previous page in Laravel

return back();
Info

Watch a video course: Learn object oriented PHP

You can also pass a fallback URL as a parameter to the back function, which will be used if the user was not referred from another page.

Example:

Example of passing a fallback URL as a parameter to the back() function in Laravel

return back('home');

This will redirect the user to the home page if they were not referred from another page.