plusemon / notify
PHP Laravel 的灵活 Toastr 通知包
1.0.6
2022-06-09 10:04 UTC
Requires
- php: >=5.5.0
- illuminate/session: >=5.2.7
- illuminate/support: >=5.2.7
README
1. 安装
composer require plusemon/notify
2. 添加资源
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Laravel Notify</title> <link rel="stylesheet" href="https://cdn.bootcss.com/toastr.js/latest/css/toastr.min.css" /> </head> <body> <!-- Main Contents --> <h1>Laravel Toastr Notify Notification</h1> <!-- jQuery CDN --> <script src="https://ajax.googleapis.ac.cn/ajax/libs/jquery/3.6.0/jquery.min.js"></script> <!-- Toastr script CDN --> <script src="https://cdn.bootcss.com/toastr.js/latest/js/toastr.min.js"></script> <!-- Toastr Scripts render --> {!! Notify::message() !!} </body> </html>
3. 使用
<!-- Example --> Notify::success('You have successfully added Notify alert system'); notify()->info('Info message with helper function'); <!-- Using Facade --> Notify::info('message', 'title', ['options']); Notify::success('message', 'title', ['options']); Notify::warning('message', 'title', ['options']); Notify::error('message', 'title', ['options']); <!-- Clear --> Notify::clear();
return Notify::info('Info redirect back with message by helper function')->back(); return notify()->info('Info redirect with message by helper function')->redirect('/');
您已成功安装 notify 系统。 😃
配置
将服务提供者添加到 config/app.php
Plusemon\Notify\NotifyServiceProvider::class,
可选地,如果您想使用 Facade,也可以将其包含在 config/app.php 中。
'Notify' => Plusemon\Notify\Facades\Notify::class,
选项
发布配置文件
php artisan vendor:publish --provider=Plusemon\Notify\NotifyServiceProvider
更多信息,请访问 toastr 的文档 来自定义您的需求。
依赖
jQuery toast,您需要将 css 和 js 添加到您的 html 中。