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();

<div class="alert alert-info flex not-prose"> Watch a course <span class="hidden md:block">Watch a video course </span> Learn object oriented PHP</div>

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.