From the course: Building a Website with Laravel, React.js, and Inertia

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Solution: Show a flash message

Solution: Show a flash message

(upbeat music) - [Instructor] How did it go? Did you manage to implement the flash messages? Let me show you how I did it. What I need to do first is to share the flash messages on each request in the HandleInitialRequest.php file. Initial already shares the user data, which is useful if you use the authentication functionality Larval Breeze comes with. I'm going to add a flash array, which features the message from the session, and saves it in the message variable. Next, I need to pass the session data to the view from the controller. For each method, I will send the message flash data with a custom message. Finally, I'm going to display the message in the post index component, because it is here where the flash message will appear. I need to import the use page hook, which will give us access to the page data. Then I need to extract the property flash from the object returned by use page props. If you wanted to see what is in this object, we can simply console log it. You can see we…

Contents