arthurguy/notifications
最新稳定版本:1.0.0
Composer 安装命令:
composer require arthurguy/notifications
包简介
Notifications
README 文档
README
Installation
First, pull in the package through Composer.
"require": { "arthurguy/notifications": "~1.0" }
And then, if using Laravel 5, include the service provider within app/config/app.php.
'providers' => [ 'ArthurGuy\Notifications\NotificationServiceProvider' ];
And, for convenience, add a facade alias to this same file at the bottom:
'aliases' => [ 'Flash' => 'ArthurGuy\Notifications\NotificationFacade' ];
Usage
Within your controllers, before you perform a redirect...
public function store() { Notification::message('Welcome Aboard!'); return Redirect::home(); }
You may also do:
Notification::info('Message')Notification::success('Message')Notification::error('Message')Notification::warning('Message')
Again, if using Laravel, this will set a few keys in the session:
- 'flash_notification.message' - The message you're flashing
- 'flash_notification.details' - A MessageBag object, ideal for field error messages
- 'flash_notification.level' - A string that represents the type of notification (good for applying HTML class names)
Alternatively, again, if you're using Laravel, you may reference the flash() helper function, instead of the facade. Here's an example:
/**
* Destroy the user's session (logout).
*
* @return Response
*/
public function destroy()
{
Auth::logout();
notification()->success('You have been logged out.');
return home();
}
Or, for a general information flash, just do: notification('Some message');.
With this message flashed to the session, you may now display it in your view(s). Maybe something like:
@if (Session::has('flash_notification.message'))
<div class="alert alert-{{ Session::get('flash_notification.level') }}">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
{{ Session::get('flash_notification.message') }}
</div>
@endif
统计信息
- 总下载量: 764
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-06-16