定制 brian2694/laravel-toastr 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

brian2694/laravel-toastr

最新稳定版本:5.59

Composer 安装命令:

composer require brian2694/laravel-toastr

包简介

toastr.js for Laravel

README 文档

README

Inspired in whossun/laravel-toastr..

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

laravel-toastr

Laravel Version Is Working?
10.x Yes
9.x Yes
8.x Yes
7.x Yes
6.x Yes
>= 5.5 Yes
<= 5.4 Yes

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>

Use ViteJs / script type defaults to module

You can also set Toastr to use vitejs by default by registering Toastr::useVite() inside the AppServiceProvider.

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Brian2694\Toastr\Facades\Toastr;

class AppServiceProvider extends ServiceProvider
{
    public function boot(): void
    {
        Toastr::useVite();
    }
}

Upon registering, you can now use Toastr::message() and it set the script type to module.

Contributors

We'd like to thank the following individuals for their contributions to this project:

  • Antonio Bruno - Set DOC on the Facade class.
  • aoradev44 - Set toastr message script type to module for using with vite

统计信息

  • 总下载量: 604.95k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 135
  • 点击次数: 1
  • 依赖项目数: 5
  • 推荐数: 0

GitHub 信息

  • Stars: 131
  • Watchers: 5
  • Forks: 38
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-01-28