From the course: Laravel Essential Training

Unlock the full course today

Join today to access over 25,100 courses taught by industry experts.

Show flash data to users

Show flash data to users - Laravel Tutorial

From the course: Laravel Essential Training

Show flash data to users

We don't have any notes right now, so let's quickly create one. New note. New note. Some text here. Click on "Save". All right. We saved the note, we redirected. We have been editing notes, deleting, creating, all of that. But we are not giving user feedback if the action was a success or not. In Laravel, this can be done with flashed session data. Let's start with the update action. Once the note has been updated, we redirect the user to the show route. Open the NoteController, and right here in the update action, we're redirecting the user to the show route, but the user has no idea if it was a success or not. So here let's pass a success message with success. You know, something like changes saved. Okay. Now, in the show blade view at the top, let's check if we have any session data with success. We can do that using @if (session('success')). So if we have any data, @endif, then we display this message. So you can use a paragraph tag. With some styles like, you know, maybe you can…

Contents