Language

How To Show Save Success (Flash) Message in Laravel 5.4

Date 13 May, 2017

Details :

1. Just add this code before your redirect code:

$request->session()->flash('alert-success', 'Data updated successfully!');

2. For Example

 public function deleteposts()
   { 
       $userdata = DB::table('posts')->where('id', 1)->delete();

       $request->session()->flash('alert-success', 'Post deleted sucessfully');

       return Redirect::back();                  
   }

3. and just paste this code in your view (blade file)

  <div class="flash-message">
       @foreach (['danger', 'warning', 'success', 'info'] as $msg)
         @if(Session::has('alert-' . $msg))

           <p class="alert alert-{{ $msg }}">{{ Session::get('alert-' . $msg) }}
            <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
           </p>
         @endif
      @endforeach
  </div>