genealabs / bones-flash
7.0.2
2020-03-06 14:57 UTC
Requires
- illuminate/session: ^7.0
- illuminate/support: ^7.0
- jenssegers/model: ^1.3
Requires (Dev)
- laravel/laravel: ^7.0
- php-coveralls/php-coveralls: ^2.2
- phpmd/phpmd: ^2.7
- phpunit/phpunit: ^8.5
- sebastian/phpcpd: ^5.0
This package is auto-updated.
Last update: 2021-06-08 22:50:16 UTC
README
目标
提供一种即插即用的、全局警报功能,以便在用户进行操作时向用户显示各种类型的警报和通知。
先决条件
- Bootstrap 3 或 4
- Laravel 5.5 或 5.6
- PHP >= 7.1.3
功能
- 以 Bootstrap 警报或模态框的形式提供反馈通知。
- 从外观、app IoC 引用或 blade 指令发送通知。
- 通过 blade 命令轻松显示通知。
安装
composer require genealabs/laravel-messenger
无需执行其他操作,因为服务提供者和外观将自动加载。
配置
如果您需要更改默认配置,请运行以下命令以发布配置文件 config\genealabs-laravel-messenger.php
php artisan messenger:publish --config
之后,您可以根据需要配置配置
/* |-------------------------------------------------------------------------- | CSS Framework Configuration |-------------------------------------------------------------------------- | | Here you may configure the CSS framework to be used by Messenger for | Laravel. This allows you to switch or upgrade frameworks without | having to recreate all your alerts. | | Available Settings: "bootstrap3", "bootstrap4" | */ 'framework' => 'bootstrap4', /* |-------------------------------------------------------------------------- | JavaScript Blade Section |-------------------------------------------------------------------------- | | Your layout blade template will need to have a section dedicated to | inline JavaScript methods and commands that are injected by this | package. This will eliminate conflicts with Vue, as well as | making sure that JS is run after all deps are loaded. | */ 'javascript-blade-section' => 'js',
用法
- 使用外观/IoC 辅助工具或另一个视图中的 blade 指令触发警报
// IoC helper: app('messenger')->send('message', 'title', 'level', autoHide, 'framework'); // Facade: Messenger::send('message', 'title', 'level', autoHide, 'framework'); // Blade directive: @send ('message', 'title', 'level', autoHide, 'framework')
- 将占位符添加到您的布局 blade 文件中
<div class="container"> @deliver </div>
参数
message
string|required
您想要发送给用户的消息内容。这可能包含 HTML。如果您添加链接,请确保添加您所使用框架的适当类。
title
string | optional | default: ''
通知的标题,将作为 <h4>
标签插入,也可以包含 HTML。同样,请记住添加任何框架特定的格式。
level
string | optional | default: 'info'
如果提供,必须是以下之一:'info'、'success'、'warning'、'danger'。
autoHide
boolean | optional | default: false
允许您在 15 秒后自动消失通知。如果 autoHide 为 false,则用户将在警报中看到一个关闭按钮。
framework
string | optional | default: 'bootstrap3'
指定您正在使用的框架。目前仅支持 'bootstrap3' 或 'bootstrap4'。
类型
字符串 | 可选 | 默认: 'alert'
调用任何可用的警报模式。目前仅支持 'alert' 或 'modal'。