How to show Save success message in Laravel 5.1?
Stefan Bogdanescu
Founder & Senior Architect · 2026-06-29
In your Laravel 5.1 application, you have successfully saved data to the database using the Controller's store method as shown above. Now let's discuss how to display a success message when saving data is successful. There are multiple ways of accomplishing this and we will cover them briefly.
Using Session Messages
Laravel offers an extremely convenient way to handle messages, either for success or errors, using the session messages feature. To display a success message when saving data in Laravel 5.1, you can simply add this code immediately after calling the save() method:
Session::flash('success', 'Seeder successfully saved!');This will store the specified success message ("Seeder successfully saved!") in the session and show it next time a view is rendered. You can display this flash message from the views using the following code:
{{ Session::get('success') }}Using Messages in Blade Templates
Alternatively, you can define messages directly within your view templates as shown below:
@if (Session::has('success'))
<div class="alert alert-success">
{{ Session::get('success') }}
</div>
@endifUsing Validation Messages
Another approach is to include validation messages in your Laravel 5.1 application. These messages can be used both for error and success notifications. To display a custom save success message, you can follow these steps:
1. In your controller, define an array of validation rules and a custom message for each field.$messages = [
'name' => 'The name field should be unique and not blank.',
'address' => 'The address cannot be empty.',
'age' => 'Please enter your age.',
];$this->validate($request,[
'name'=>'required|unique:seeders|max:255',
'address'=>'required',
'age'=>'required',
], $messages);if ($validator->fails()) {
return redirect()->back()->withErrors($validator)->withInput();
}@if ($errors->any())
<div class="alert alert-danger">
@foreach ($errors->all() as $error)
{{ $error }}<br>
@endforeach
</div>
@endif