Flash notification that accepts a array and string. You can use it from your controller and also in the views.
composer require gertjanroke/notification
Add the following line to config/app.php
.
at providers
:
Gertjanroke\Notification\NotificationServiceProvider::class,
And at aliases
:
'Notification' => Gertjanroke\Notification\Facade\Notification::class,
Run the following command:
php artisan vendor:publish
To see the flash notification(s), you need to add the following @include()
.
@include('notification::message')
And if you want the basic styling that comes with the package, also inlcude the following lines:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="{{ asset('assets/css/notification-style.css') }}">
And the javascript:
<script src="{{ asset('assets/js/notification.js') }}"></script>
Creating a notification can be done with the next commands:
Notification::
- success()
- error()
- warning()
- info()
- overlay() // Bootstrap modal
You can also add the class "Important" to the alert message, with the following command:
Notification::error('message', 'title')->important();
You can send a message as a string or as a array.
Syntax:
Notification::success([
'First success',
'Second success title' => [
'First success',
'Second success'
],
'Third success'
]);
Notification::success('First success');
The last string is the title. You have two options: give a string or leave it blank.
With title:
Notification::success('First success', 'Title success block');
Without title:
Notification::success('First success');
When you want to use a Modal from bootstrap you can do so with the following function and syntax:
Notification::overlay( 'Message', 'Title' );
You can also create a notification from the view file, this is usefull when your using a ajax form.
Creating a notification can be done with the next commands:
Notification.
- success()
- error()
- warning()
- info()
- overlay() // Bootstrap modal
You can send a message as a string or as a array.
The following syntax is used at all functions but NOT FOR: .overlay()
:
Single message:
Notification.success( 'First message' );
Multiple single messages:
Notification.success( ['First message', 'Second message', 'Third message'] );
Grouping messages:
Notification.success( {'Third message with array': ['First message', 'Second message']} );
Grouping messages inside a Array of messages:
Notification.success( ['First message', 'Second message', {'Third message with array': ['First message', 'Second message']}] );
Adding a title to a notification:
Notification.success( 'message', 'The Title goes after the message' );
Adding the class important
to your notification is easly done with adding a boolean as last variable:
Notification.success( 'message', 'Title', TRUE );
When you want to use a Modal from bootstrap you can do so with the following function and syntax:
Notification.overlay( 'Message', 'Title', 'Button text' );