brian2694 / laravel-toastr by brian2694

toastr.js for Laravel
351,390
125
6
Package Data
Maintainer Username: brian2694
Maintainer Contact: briansanchez2694@gmail.com (brian2694)
Package Create Date: 2017-01-28
Package Last Update: 2024-01-02
Language: PHP
License: MIT
Last Refreshed: 2024-04-19 15:00:45
Package Statistics
Total Downloads: 351,390
Monthly Downloads: 10,556
Daily Downloads: 444
Total Stars: 125
Total Watchers: 6
Total Forks: 37
Total Open Issues: 0

Inspired in whossun/laravel-toastr.

I cloned the repository brian2694/laravel-toastr to update to Laravel 5.5

laravel-toastr

install

Using Composer

composer require brian2694/laravel-toastr

Laravel >= 5.5

That's it! The package is auto-discovered on 5.5 and up!

Laravel <= 5.4

Add the service provider to config/app.php

Brian2694\Toastr\ToastrServiceProvider::class,

Optionally include the Facade in config/app.php if you'd like.

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

Options

You can set custom options for Reminder. Run:

php artisan vendor:publish

to publish the config file for toastr.

You can see toastr's documentation to custom your need.

You can use toastr() function available.

Dependencies

jQuery toast, you need to add css and js to your html.

Basic

  • Toastr::info('message', 'title', ['options']);

  • Toastr::success('message', 'title', ['options']);

  • Toastr::warning('message', 'title', ['options']);

  • Toastr::error('message', 'title', ['options']);

  • Toastr::clear();

  • Toastr()->info('message', 'title', ['options']);

<?php

Route::get('/', function () {
    Toastr::success('Messages in here', 'Title', ["positionClass" => "toast-top-center"]);

    return view('welcome');
});

Then

You should add {!! Toastr::message() !!} to your html.

<!DOCTYPE html>
<html>
    <head>
        <title>Laravel</title>
        <link rel="stylesheet" href="http://cdn.bootcss.com/toastr.js/latest/css/toastr.min.css">
    </head>
    <body>
        <div class="container">
            <div class="content">
                <div class="title">Laravel 5</div>
            </div>
        </div>
		<script src="http://cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
        <script src="http://cdn.bootcss.com/toastr.js/latest/js/toastr.min.js"></script>
        {!! Toastr::message() !!}
    </body>
</html>

MIT