@filiberto
To show a message after filtering in Laravel, you can follow these steps:
1 2 3 4 5 6 7 8 |
public function filterData(Request $request) { // Your filter logic goes here session()->flash('message', 'Filter applied successfully.'); return redirect()->route('your.route.name'); } |
1 2 3 4 5 6 |
<!-- Your blade view file --> @if (session('message')) <div class="alert alert-success"> {{ session('message') }} </div> @endif |
This code checks if the message
key exists in the session and if it does, it displays an alert div with the message content. The session('message')
retrieves the value of the message
key from the session.
With these steps, after applying the filter, a success message will be shown to the user on the redirected page.