augstudios/alerts
Composer 安装命令:
composer require augstudios/alerts
包简介
Package for sending alerts with Laravel 5.
README 文档
README
About
This package is in very early initial development, things are very likely going change before a stable release is tagged.
Alerts is a Laravel 5 package that allows you to easily flash alerts to the Session to be consumed on the next request.
Installation
First, install the package and it's dependencies with composer by running within your application's root folder:
composer require augstudios/alerts
Then, you will need to add the the Alerts service provider and facade to your application's configuration in /app/config/app.php.
'providers' => [
...
'Augstudios\Alerts\AlertsServiceProvider'
];
...
'aliases' => [
...
'Alerts' => 'Augstudios\Alerts\AlertsFacade'
];
Usage
To flash messages, to be displayed on the next request, you can use the Alerts::flash(message, type) method:
public function save()
{
Alerts::flash('Welcome Aboard!', 'info');
return Redirect::home();
}
There also exists some shortcut methods for each alert type:
Alerts::flashInfo('Info message');
Alerts::flashWarning('Warning message');
Alerts::flashDanger('Danger message');
Alerts::flashSuccess('Success message');
To get the previously flashed alerts, use the Alerts::all() method:
foreach(Alerts::all() as $alert){
// this is likely to change so Alert is an object
// $alert['message'] has message
// $alert['type'] has type
// $alert['dismissiable']
}
If you only want one type of alert, you can use the Alerts::ofType(type) method:
Alerts::ofType('info');
Alerts::ofType('warning');
Alerts::ofType('danger');
Alerts::ofType('success');
统计信息
- 总下载量: 25
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-03-02