wl496928838 / laravel-toastr by wl496928838

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.
73
0
2
Package Data
Maintainer Username: wl496928838
Maintainer Contact: csuilong@gmail.com (chensuilong)
Package Create Date: 2017-03-23
Package Last Update: 2017-04-09
Language: PHP
License: MIT
Last Refreshed: 2024-04-19 15:01:40
Package Statistics
Total Downloads: 73
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 0
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

laravel-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.

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.