oriceon/toastr-5-laravel

Easy toastr notifications for Laravel 5
495,152 79
Install
composer require oriceon/toastr-5-laravel
Latest Version:2.0.0
PHP:>=5.4.0
License:MIT
Last Updated:Mar 16, 2024
Links: GitHub  ·  Packagist
Maintainer: oriceon

toastr

Easy toastr.js notifications for Laravel 5, a ported version of Laravel 4 Toastr by kamaln7

Installation

  1. Either run composer require oriceon/toastr-5-laravel or add "oriceon/toastr-5-laravel": "dev-master" to the require key in composer.json and run composer install
  2. Add 'Kamaln7\Toastr\ToastrServiceProvider', to the providers key in config/app.php (optional for Laravel 5.5)
  3. Add 'Toastr' => 'Kamaln7\Toastr\Facades\Toastr', to the aliases key in config/app.php (optional for Laravel 5.5)

Usage

Include jQuery and toastr.js in your master view template, and the output of Toastr::render() afterwards:

<link href="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.min.css" rel="stylesheet">
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/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 toast
  • Toastr::error($message, $title = null, $options = []) - add an error toast
  • Toastr::info($message, $title = null, $options = []) - add an info toast
  • Toastr::success($message, $title = null, $options = []) - add a success toast
  • Toastr::add($type: warning|error|info|success, $message, $title = null, $options = []) - add a toast
  • Toastr::clear() - clear all current toasts

Setting custom Toastr options

You can set custom options for Toastr. Run:

php artisan vendor:publish

to publish the config file for Toastr. Then edit config/toastr.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.

Related Packages

brian2694/laravel-toastr

toastr.js for Laravel

757,339 131
whossun/laravel-toastr

toastr.js for laravel 5.2

2,837 4
narutimateum/toastr-5.2-laravel

toastr.js for Laravel 5.2 easy notification like growl for example

37,567 13
nilsenj/toastr-5.1-laravel

toastr.js for Laravel 5.1/5.2 easy notification like growl for example

33,955 6
nilsenj/toastr-laravel

toastr.js for Laravel 5.* easy notification like growl for example

9,013 7