From your application, call the flash method with a message and type.
notify('Welcome back!'); // The default type is 'info'
notify('Welcome back!', 'success');
notify()->flash('Welcome back!', 'success');
Within a view, you can now check if a flash message exists and output it.
@if (notify()->isNotEmpty())
@foreach(notify()->notifications() as $notification)
<div class="alert-box {{ $notification['type'] }}">
{{ $notification['message'] }}
</div>
@endforeach
@endif
Notify is front-end framework agnostic, so you're free to easily implement the output however you choose (Like Twitter bootstrap, Zurb Foundation, Semantic UI ...).
You can pass additional extra
options to the flash
method, which are then easily accessible within your view.
notify()->flash("Great to see you again, Bruh!", 'success', [
'title' => 'Welcome back!',
'icon' => 'success-icon',
]);
Then, in your view.
@if (notify()->isNotEmpty())
@foreach(notify()->notifications() as $notification)
<div class="alert-box {{ $notification['type'] }}">
<h5><i class="{{ $notification['extra']['icon'] ?? 'default-icon' }}"></i> {{ $notification['extra']['title'] ?? 'Default Title' }}</h5>
<p>{{ $notification['message'] }}</p>
</div>
@endforeach
@endif