ghanem / notify
带有图标和动画以及超时功能的Laravel 5 Flash Notifications
v1.01
2017-06-30 09:50 UTC
Requires
- php: >=5.4.0
This package is auto-updated.
Last update: 2024-09-16 22:11:42 UTC
README
将通知消息框推送到浏览器,并为其提供飞出超时功能。在成功执行操作(CRUD)后通知用户效果很好。可以从Laravel闪烁信息或使用javascript创建多个。
安装
首先,通过Composer拉取此包。
"require": { "ghanem/notify": "1.*" }
或者
composer require ghanem/notify
在config\app.php
中包含服务提供者。
'providers' => [ Ghanem\Notify\NotifyServiceProvider::class, ];
添加外观别名或使用全局辅助函数notify()
。
'aliases' => [ 'Notify' => Ghanem\Notify\Facades\Notify::class, ];
用法
在任意视图文件中(最好是您的母版布局)。
@include('notify::notify')
在任意控制器中。
public function index() { // helper function - default to the 'info' notify('Content'); // return object first notify()->info('Content'); // via the facade Notify::info('Content'); return view('home'); }
不同的'级别'有
notify()->info('内容');
notify()->success('内容');
notify()->warning('内容');
notify()->error('内容');
不同的参数
notify()->info('content', 10000, false);
// 没有取消按钮
如果您需要修改视图部分,可以执行
php artisan vendor:publish --provider="Ghanem\Notify\NotifyServiceProvider" --tag=view
视图部分可以在以下位置找到:resources\views\vendor\notify\notify.blade
。
您需要发布资源。
php artisan vendor:publish --provider="Ghanem\Notify\NotifyServiceProvider" --tag=public
文件在这里:public\vendor\notify\
。将mp3文件移动到public\sounds\
。如果您使用Laravel Elixir,将css和js文件移动到您的resource\assets
,并在gulpfile.js中包含它们,否则在html头中链接到单个文件。
注意
请记住,这仅适用于我的个人工作流程,可能不适合您的需求。我开发这个是为了帮助加快我的日常工作流程。请告诉我任何问题或建议。