Skip to content

Latest commit

 

History

History
65 lines (48 loc) · 1.56 KB

3-Usage.md

File metadata and controls

65 lines (48 loc) · 1.56 KB

3. Usage

Table of contents

  1. Installation and Setup
  2. Configuration
  3. Usage

Basic Usage

From your application, call the flash method with a message and type.

notify('Welcome back!'); // The default type is 'info'
OR
notify('Welcome back!', 'success');
OR
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 ...).

Extra Options

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