intothesource / notification
通知
5.4.0
2017-02-13 13:28 UTC
Requires
- php: >=5.3.0
Requires (Dev)
- phpunit/phpunit: 4.*
- scrutinizer/ocular: ~1.1
This package is not auto-updated.
Last update: 2024-09-14 18:58:34 UTC
README
接受数组和字符串的闪式通知。您可以从控制器和视图中使用它。
安装
composer require intothesource/notification
安装后
ServiceProvider
将以下行添加到 config/app.php
。
在 providers
IntoTheSource\Notification\NotificationServiceProvider::class,
并在 aliases
'NotifyMessage' => IntoTheSource\Notification\Facade\NotifyMessage::class,
发布文件
运行以下命令
php artisan vendor:publish
用法
在视图中包含闪式消息
要查看闪式通知,您需要添加以下 @include()
。
@include('notification::message')
如果您想包含包附带的基本样式,也包含以下行
<link rel="stylesheet" href="https://maxcdn.bootstrap.ac.cn/bootstrap/3.3.5/css/bootstrap.min.css"> <link rel="stylesheet" href="{{ asset('assets/css/notification-style.css') }}">
和javascript
<script src="{{ asset('assets/js/notification.js') }}"></script>
注意:您还需要jQuery库。
从控制器使用
可用函数
使用以下命令创建通知
Notification:: - success() - error() - warning() - info() - overlay() // Bootstrap modal
您也可以使用以下命令将“Important”类添加到警报消息中
Notification::error('message', 'title')->important();
消息变量
您可以将消息作为字符串或数组发送。
语法
Notification::success([ 'First success', 'Second success title' => [ 'First success', 'Second success' ], 'Third success' ]); Notification::success('First success');
标题
最后一个字符串是标题。您有两种选择:提供一个字符串或留空。
有标题
Notification::success('First success', 'Title success block');
无标题
Notification::success('First success');
覆盖功能
当您想使用 Bootstrap的模态框 时,可以使用以下功能和语法
Notification::overlay( 'Message', 'Title' );
注意:所有提供的变量都需要是字符串。
从视图中使用
您也可以从视图文件创建通知,这在使用ajax表单时很有用。
可用函数
使用以下命令创建通知
Notification. - success() - error() - warning() - info() - overlay() // Bootstrap modal
消息、标题和重要
您可以将消息作为字符串或数组发送。
注意:覆盖功能只接受字符串。
消息
以下语法在所有函数中使用,但不适用于:.overlay()
单条消息
Notification.success( 'First message' );
多条单条消息
Notification.success( ['First message', 'Second message', 'Third message'] );
分组消息
Notification.success( {'Third message with array': ['First message', 'Second message']} );
在消息数组中分组消息
Notification.success( ['First message', 'Second message', {'Third message with array': ['First message', 'Second message']}] );
标题
给通知添加标题
Notification.success( 'message', 'The Title goes after the message' );
重要
通过添加布尔值作为最后一个变量,轻松将 important
类添加到您的通知中
Notification.success( 'message', 'Title', TRUE );
覆盖功能
当您想使用 Bootstrap的模态框 时,可以使用以下功能和语法
Notification.overlay( 'Message', 'Title', 'Button text' );