Skip to content

Instantly share code, notes, and snippets.

@shishircse06
Created July 6, 2016 14:21
Show Gist options
  • Save shishircse06/c03b212fa26e43f27308beef16c5b85f to your computer and use it in GitHub Desktop.
Save shishircse06/c03b212fa26e43f27308beef16c5b85f to your computer and use it in GitHub Desktop.
Laravel flash message
Session::flash('message', 'This is a message!');
Session::flash('alert-class', 'alert-danger');
In view:
@if(Session::has('message'))
<p class="alert {{ Session::get('alert-class', 'alert-info') }}">{{ Session::get('message') }}</p>
@endif
OR:
In controller:
Session::flash('alert-danger', 'danger');
Session::flash('alert-warning', 'warning');
Session::flash('alert-success', 'success');
Session::flash('alert-info', 'info');
Session::flash('message', 'This is a message!');
In View:
<div class="flash-message">
@foreach (['danger', 'warning', 'success', 'info'] as $msg)
@if(Session::has('alert-' . $msg))
<p class="alert alert-{{ $msg }}">{{ Session::get('message') }}</p>
@endif
@endforeach
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment