Implements toastr.js for Laravel. Toastr.js is a Javascript library for non-blocking notifications.
To install a plugin via Bower run
bower install toastr
You can also install the package via composer:
composer require palpalani/laravel-toastr
Publish the config file with
php artisan vendor:publish --provider="palPalani\Toastr\ToastrServiceProvider" --tag="laravel-toastr-config"
This is the contents of the published config file:
return [
'options' => [
"progressBar" => true,
"positionClass" =>"toast-bottom-right",
"preventDuplicates"=> false,
"showDuration" => 300,
"hideDuration" => 1000,
"timeOut" => 5000,
"extendedTimeOut" => 1000,
"showEasing" => "swing",
"hideEasing"=> "linear",
"showMethod" => "fadeIn",
"hideMethod" => "fadeOut",
]
];
If you want, edit config/toastr.php
and set the options
array to whatever you want to pass to Toastr (this step is optional). These options are set as
the default options and can be overridden by passing an array of options to any of the methods in the Usage section.
Include jQuery, toastr.js and plugin styles in your master view template.
Link to toastr.min.css:
<link href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css" rel="stylesheet"/>
Link to toastr.min.js:
<script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"></script>
After everything is done, insert the string below in your template just before body closing tag or after toastr.js script instantiated in your file.
{!! Toastr::render() !!}
Then use these methods in your controllers to insert a toast:
Toastr::warning($message, $title = null, $options = [])
- add a warning toastToastr::error($message, $title = null, $options = [])
- add an error toastToastr::info($message, $title = null, $options = [])
- add an info toastToastr::success($message, $title = null, $options = [])
- add a success toastToastr::add($type: warning|error|info|success, $message, $title = null, $options = [])
- add a toastToastr::clear()
- clear all current toasts don't forget to use it
For a list of available options, see toastr.js' documentation.
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
We use SemVer for versioning. For the versions available, see the tags on this repository.
The MIT License (MIT). Please see License File for more information.