How to show success message in laravel 8

How to display success message in laravel 8


In this article, you will be learning how to show / display a success message in laravel 8.

So guys, basically after form submit or any request performed, we want to show success message.

Lets see with few example as given below to display success message:
 

Example 1: 

this below code is performed on your controller side:

return redirect()->back()->with('message',"This is Success Message");

Displaying message if it exists. (in blade file):

@if(session()->has('message'))
    <div class="alert alert-success">
        {{ session()->get('message') }}
    </div>
@endif


Example 2: 

this below code is performed on your controller side:

return redirect()->back()->with('message',"This is Success Message");

Displaying message if it exists. (in blade file):

@if(session('message'))
    <h6 class="alert alert-success">
        {{ session('message') }}
    </h6>
@endif


Thanks for reading.