roksta21 / Toast by sam_roksta

Toastr notifications in laravel
1,713
3
2
Package Data
Maintainer Username: sam_roksta
Maintainer Contact: roksta21@gmail.com (roksta)
Package Create Date: 2016-10-27
Package Last Update: 2019-10-15
Language: PHP
License: MIT
Last Refreshed: 2024-11-22 03:10:14
Package Statistics
Total Downloads: 1,713
Monthly Downloads: 5
Daily Downloads: 0
Total Stars: 3
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

Toast

Simple toastr notifications for laravel

Installation

Install Toastr via npm

    npm install toastr --save

Require the js in resources/assets/js/bootstrap.js as window.toastr = require('toastr');

Import the sass in resources/assets/sass/app.scss as @import "node_modules/toastr/toastr"; then build via npm npm run prod.

Install via composer

    composer require roksta/toast

Laravel will automatically discover the provider and the alias.

Run

php artisan vendor:publish --provider="Roksta\Toastr\ToastrServiceProvider"

to publish the package view in your resources/assets/vendor/roksta/toastr.blade.php

Add @include('vendor.roksta.toastr') in your main view, eg,

    <!DOCTYPE html>
    <html>
    <head>
        <title></title>
        <link rel="stylesheet" type="text/css" href="/css/app.css">
    </head>
    <body>
        <div id="app"></div>
        <script type="text/javascript" src="js/app.js"></script>
        @include('vendor.roksta.toastr')
    </body>
    </html>

Use

Just use the helper function toast() to make the notifier.

    toast()->success('message', 'title');
    toast()->info('message', 'title');
    toast()->warning('message', 'title');
    toast()->error('message', 'title');

You may specify the timeout duration by

    toast()->success('message', 'title')->timeOut(5000);