Laravel redirect back


Laravel redirect back : Redirect::back(); is used to redirect back the users from the current url to the back url. Here in this tutorial we are going to explain how you can redirect from current url to back url with errors in laravel.


Laravel redirect back

You can redirect back to the previous url in laravel as below –

Laravel redirect back:

Session::flash('message', "Data saved successfully.");
Redirect::back();

The above example will redirect back to previous url with the given message.

Now to display the message add the following flash message to display it-

Laravel redirect back with message:

@if (Session::has('message'))
   {{ Session::get('message') }}
@endif

The above example will display the message added in the redirect back url.


Advertisements

Add Comment

📖 Read More