Giter Club home page Giter Club logo

toastr's Introduction

Toastr for Laravel

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.

toastr's People

Contributors

itssamtaylor avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.