How to display a success message upon redirection from controller in Laravel?
return redirect('/')->with('message', 'Message sent!');
Read more about redirects in Laravel.
Be sure that Session is working properly to get flash message working.
ikartik90
I'm a programmer turned UX designer living in New Delhi, India. I love working on dashboards, creating wireframes, and solving challenging design problems through research and understanding. I generally use Photoshop, Illustrator and XD to create my designs and prototypes. Though I've even jumped on and off to other tools like Origami and InVision as needed. And when nothing seems to serve the purpose, I just pick up a few sheets of paper and my favorite ball point pen and start scribbling stuff down to figure something out.
Updated on June 04, 2022Comments
-
ikartik90 almost 2 years
In my application I have a form that validates and inserts records into the table.
Upon successful insertion into the table the controller
redirect()
s back to the page ass follows:return redirect('/');
This works fine, except for the fact that it doesn't tell the user of whether the insertion took place at all or not as only the blank form remains on the page while no success message is displayed.
How can I redirect along with data (some form of
return code
) so that I can display a simple success message?