laravel-toastr
install
Using Composer, (*1)
composer require whossun/laravel-toastr
Add the service provider to config/app.php, (*2)
Whossun\Toastr\ToastrServiceProvider::class,
Optionally include the Facade in config/app.php if you'd like., (*3)
'Toastr' => Whossun\Toastr\Facades\Toastr::class,
Options
You can set custom options for Reminder. Run:, (*4)
php artisan vendor:publish
to publish the config file for toastr., (*5)
You can see toastr's documentation to custom your need., (*6)
You can use toastr() function available., (*7)
Dependencies
jQuery toast, you need to add css and js to your html., (*8)
Basic
-
Toastr::info('message', 'title', ['options']);, (*9)
-
Toastr::success('message', 'title', ['options']);, (*10)
-
Toastr::warning('message', 'title', ['options']);, (*11)
-
Toastr::error('message', 'title', ['options']);, (*12)
-
Toastr::clear();, (*13)
-
Toastr()->info('message', 'title', ['options']);, (*14)
<?php
Route::get('/', function () {
Toastr::success('Messages in here', 'Title', ["positionClass" => "toast-top-center"]);
return view('welcome');
});
Then, (*15)
You should add {!! Toastr::message() !!} to your html., (*16)
<!DOCTYPE html>
<html>
<head>
<title>Laravel</title>
<link rel="stylesheet" href="http://cdn.bootcss.com/toastr.js/latest/css/toastr.min.css">
</head>
<body>
<div class="container">
<div class="content">
<div class="title">Laravel 5</div>
</div>
</div>
<script src="http://cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
<script src="http://cdn.bootcss.com/toastr.js/latest/js/toastr.min.js"></script>
{!! Toastr::message() !!}
</body>
</html>
MIT