Skip to content
Advertisement

Laravel 4 – Redirect back to the same page where the request comes from

In Laravel 4, I want to redirect the user back to the page from where the request came. For example, a user tries to update his profile so edits the profile and hits SAVE. In controller I do the update and normally I would do Redirect::to('profile')->with('message','Profile saved!'). But what I want is to simply redirect it back with message. May be something like Redirect::back()->with('message','Operation Successful !') if this is available. I want it as it is more generic and I can use it anywhere.

Advertisement

Answer

Yes this is available:

return Redirect::back()->with('message','Operation Successful !');

But since this is a redirected request, you have to access the message by using:

echo Session::get('message');
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement