csl / toastr
Support laravel5.* toastr is a Javascript library for non-blocking notifications. jQuery is required. The goal is to create a simple core library that can be customized and extended.
Requires
- illuminate/support: ~5.0
This package is not auto-updated.
Last update: 2024-11-10 03:36:10 UTC
README
Support laravel5.*
toastr is a Javascript library for non-blocking notifications. jQuery is required. The goal is to create a simple core library that can be customized and extended.
Installation
Using Composer
composer require csl/toastr
Add the service provider to config/app.php
Csl\Toastr\ToastrServiceProvider::class,
Add the Facade in config/app.php
'Toastr' => Csl\Toastr\Toastr::class,
Usage
jQuery toast, you need to add css and js to your html.
<link rel="stylesheet" href="http://cdn.bootcss.com/toastr.js/latest/css/toastr.min.css"> <script src="http://cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script> <script src="http://cdn.bootcss.com/toastr.js/latest/js/toastr.min.js"></script> {!! Toastr::message() !!}
Toastr::info('foo', 'bar'); Toastr::success('foo', 'bar'); Toastr::warning('foo', 'bar'); Toastr::error('foo', 'bar');
Example
<?php Route::get('/', function () { Toastr::success('Hi! this is Toastr', 'Hello', ["positionClass" => "toast-bottom-left"]); return view('welcome'); });
<!DOCTYPE html> <html> <head> <title>Laravel</title> <link rel="stylesheet" href="http://cdn.bootcss.com/toastr.js/latest/css/toastr.min.css"> </head> <body> <script src="http://cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script> <script src="http://cdn.bootcss.com/toastr.js/latest/js/toastr.min.js"></script> {!! Toastr::message() !!} </body> </html>
Config
If you need to modify the flash message partials, you can run:
php artisan vendor:publish
to publish the config file for config/toastr.php
.
You can see toastr's documentation to custom your need.