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 - Laravel Tutorial
From the course: Building a Website with Laravel, React.js, and Inertia
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
-
-
-
-
-
(Locked)
Introduction to Inertia.js1m 16s
-
(Locked)
Getting started with a new Inertia project1m 58s
-
(Locked)
Creating a Post resource2m 29s
-
(Locked)
Creating the Home and About pages2m 14s
-
Creating an Inertia navigation2m 6s
-
(Locked)
Changing the website title2m 4s
-
(Locked)
Displaying posts3m 4s
-
(Locked)
Creating posts4m 37s
-
(Locked)
Displaying a single post1m 29s
-
(Locked)
Updating posts1m 51s
-
(Locked)
Deleting posts1m 33s
-
(Locked)
Challenge: Show a flash message1m 2s
-
(Locked)
Solution: Show a flash message2m 59s
-
(Locked)
-