定制 arthurguy/notifications 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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">&times;</button>

        {{ Session::get('flash_notification.message') }}
    </div>
@endif

统计信息

  • 总下载量: 764
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-06-16