In this episode, we're starting work on adding a toast notification (or "flash message") feature to our Inertia app. The goal is to show a message like "Welcome back, Alex!" after logging in. Since we're using Laravel Fortify for authentication, and Fortify manages its own controllers, we can't just add the flash message in a typical way. Instead, we need to take control of the login response.
We'll walk through grabbing Fortify's LoginResponse
class, copying it into our own project, and swapping it out so Laravel uses ours. This way, we can add whatever logic we want (such as flashing a message to the session) after a successful login.
On the frontend, we'll set up a very basic Vue component to display these flash messages. We then make sure that our backend's flash message is passed to the client via Inertia's share()
method. The shared data gets picked up by our Vue toast component and shown on the page.
By the end of the episode, you'll see a basic version of toast notifications tied into the login process. In future episodes, we'll refine the UI, add animations, and make the toast experience a bit slicker!