kamaln7 / toastr
Easy toastr notifications for Laravel 4
Installs: 2 261
Dependents: 0
Suggesters: 0
Security: 0
Stars: 10
Watchers: 4
Forks: 29
pkg:composer/kamaln7/toastr
Requires
- php: >=5.3.0
- illuminate/session: >=4.0.0
- illuminate/support: >=4.0.0
This package is not auto-updated.
Last update: 2020-01-20 03:23:31 UTC
README
Easy toastr.js notifications for Laravel 4
Installation
- Either run
composer require kamaln7/toastr dev-masteror add"kamaln7/toastr": "dev-master"to therequirekey incomposer.jsonand runcomposer install - Add
'Kamaln7\Toastr\ToastrServiceProvider',to theproviderskey inapp/config/app.php - Add
'Toastr' => 'Kamaln7\Toastr\Facades\Toastr',to thealiaseskey inapp/config/app.php
Usage
Include jQuery and toastr.js in your master view template, and the output of Toastr::render() afterwards:
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/toastr.js/2.0.0/js/toastr.min.js"></script> {{ Toastr::render() }}
Call one of 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
Setting custom Toastr options
You can set custom options for Toastr. Run:
php artisan config:publish kamaln7/toastr
to publish the config file for Toastr. Then edit app/config/packages/kamaln7/toastr/config.php and set the options array to whatever you want to pass to Toastr. 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.
For a list of available options, see toastr.js' documentation.