There is no license information available for the latest version (1.0.1) of this package.

A laravel class that will generate Toastr messages using toastr.js

1.0.1 2019-04-28 16:47 UTC

This package is auto-updated.

Last update: 2024-10-29 04:58:50 UTC


README

A simple facade for Laravel 5 to generate toastr message using toastr.js.

Install

Via Composer

$ composer require taylornetwork/toastr

Dependencies

You will need to include toastr.js on your pages.

You can install using bower

$ bower install toastr

or include from CDNjs.

<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css" />
<script src="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"></script>

This may not be the most up to date information, see CodeSeven/toastr

Setup

Provider Setup

Add the service provider to the providers array in your config/app.php

'providers' => [

    TaylorNetwork\Toastr\ToastrServiceProvider::class,

],

Facade Setup

Add the Toastr facade to your aliases array in config/app.php

While this is optional, it is greatly recommended because Toastr::render() will be used in your base view and is easier than having to include the Toastr class.

'aliases' => [

    'Toastr' => TaylorNetwork\Toastr\Facades\Toastr::class,

],

Publishing Config

$ php artisan vendor:publish

Will add config/toastr.php to your project.

View Setup

You will need to include the toastr.js and toastr.css files from bower or CDNjs (see Dependencies section above) in your base views.

You will also need to add the following line after both files are included in order to render Toastr messages.

// app.blade.php

<link rel="stylesheet" href="path/to/toastr.css" />
<script src="path/to/toastr.js"></script>

{!! Toastr::render() !!}

Usage

Include TaylorNetwork\Toastr\Facades\Toastr in what ever class you plan on generating a Toastr message.

By default the styles available are success, error, info, warning. But you can remove any in config/toastr.php

TaylorNetwork\Toastr\Toastr uses a magic method to generate toastr messages.

To generate a success message

Toastr::success('Congratulations!');

Will push a success message to the session and will appear on the next request.

The magic method accepts a minimum of one parameter, the text you want to be displayed. The optional second parameter is the title of the message.

To add a custom title to the toastr message

Toastr::info('This is information!', 'New Info!!!');

Credits

License

The MIT License (MIT). Please see License File for more information.