定制 cornford/notifier 二次开发

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

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

cornford/notifier

最新稳定版本:v2.2.1

Composer 安装命令:

composer require cornford/notifier

包简介

An easy way to send notification messages to a client using AJAX in Laravel.

README 文档

README

Latest Stable Version Total Downloads Build Status Scrutinizer Code Quality

For Laravel 4.x, check version 1.0.1

Think of Notifier as an easy way to send notification messages to a client using AJAX in Laravel. These include:

  • Notifier::notification
  • Notifier::none
  • Notifier::info
  • Notifier::success
  • Notifier::warning
  • Notifier::danger
  • Notifier::setOptions
  • Notifier::getOptions
  • Notifier::setNotifications
  • Notifier::getNotifications
  • Notifier::assets
  • Notifier::getDisplayNotifications
  • Notifier::displayNotifications
  • Notifier::displayedDisplayableNotifications
  • Notifier::displayedAllNotifications
  • Notifier::expireNotifications
  • Notifier::expireDisplayedNotifications
  • Notifier::expireAllNotifications
  • Notifier::fetchNotifications
  • Notifier::storeNotifications
  • Notifier::toArray

Installation

Begin by installing this package through Composer. Edit your project's composer.json file to require cornford/notifier.

"require": {
	"cornford/notifier": "1.*"
}

Next, update Composer from the Terminal:

composer update

Once this operation completes, the next step is to add the service provider. Open app/config/app.php, and add a new item to the providers array.

'Cornford\Notifier\Providers\NotifierServiceProvider',

The next step is to introduce the facade. Open app/config/app.php, and add a new item to the aliases array.

'Notifier'         => 'Cornford\Notifier\Facades\NotifierFacade',

We then need to introduce the configuration files, JavaScripts and Stylesheets, by running the following command.

php artisan vendor:publish --provider="Cornford\\Notifier\\Providers\\NotifierServiceProvider"

That's it! You're all set to go.

Usage

It's really as simple as using the Logical class in any Controller / Model / File you see fit with:

Notifier::

This will give you access to

Notification

The notification method allows you to create a notification, with parameters for message, type and expiry as an integer of minutes or DateTime object.

Notifier::notification('This is a message', Notification::NOTIFICATION_TYPE_INFO, 0);
Notifier::notification('This is a message', Notification::NOTIFICATION_TYPE_NONE, new DateTime('tomorrow'));

None

The none method allows you to create a none notification, with parameters for message and expiry as an integer of minutes or DateTime object.

Notifier::none('This is a message', 0);
Notifier::none('This is a message', new DateTime('tomorrow'));

Info

The info method allows you to create an information notification, with parameters for message and expiry as an integer of minutes or DateTime object.

Notifier::info('This is a message', 0);
Notifier::info('This is a message', new DateTime('tomorrow'));

Success

The success method allows you to create a success notification, with parameters for message and expiry as an integer of minutes or DateTime object.

Notifier::success('This is a message', 0);
Notifier::success('This is a message', new DateTime('tomorrow'));

Warning

The warning method allows you to create a warning notification, with parameters for message and expiry as an integer of minutes or DateTime object.

Notifier::warning('This is a message', 0);
Notifier::warning('This is a message', new DateTime('tomorrow'));

Danger

The danger method allows you to create a danger notification, with parameters for message and expiry as an integer of minutes or DateTime object.

Notifier::danger('This is a message', 0);
Notifier::danger('This is a message', new DateTime('tomorrow'));

Danger

The danger method allows you to create a danger notification, with parameters for message and expiry as an integer of minutes or DateTime object.

Notifier::danger('This is a message', 0);
Notifier::danger('This is a message', new DateTime('tomorrow'));

Set Options

The setOptions method allows you to set the current set of Notifier options using a parameter for options as an array.

Notifier::setOptions(['option' => 'value']);

Get Options

The getOptions method allows you to fetch the current set of Notifier options as an array.

$options = Notifier::getOptions();

Set Notifications

The setNotifications method allows you to the current set of notifications with an array of notifications objects.

Notifier::setNotifications([new Notification('This is a message', Notification::NOTIFICATION_TYPE_NONE, new DateTime('now'), 1)]);

Get Notifications

The getNotifications method allows you to the fetch the current set of notifications as an array of notifications objects.

$notifications = Notifier::getNotifications();

Assets

The assets method allows you to the include the necessary Notifier assets to your template files, with an optional parameter for type.

{!! Notifier::assets() !!}
{!! Notifier::assets('cdn') !!}

Get Display Notifications

The getDisplayNotifications method allows you to get the current set of displayable notifications.

$notifications = Notifier::getDisplayNotifications();

Display Notifications

The displayNotifications method allows you to mark an array of passed notifications as displayed.

$notifications = Notifier::getNotifications();
Notifier::displayNotifications($notifications);

Displayed Displayable Notifications

The displayedDisplayableNotifications method allows you to mark displayable notifications as displayed.

Notifier::displayedDisplayableNotifications();

Displayed All Notifications

The displayedAllNotifications method allows you to mark all notifications as displayed.

Notifier::displayedAllNotifications();

Expire Notifications

The expireNotifications method allows you to expire an array of passed notifications.

$notifications = Notifier::getNotifications();
Notifier::expireNotifications($notifications);

Expire Displayed Notifications

The expireDisplayedNotifications method allows you to expire all displayed notifications.

Notifier::expireDisplayedNotifications();

Expire All Notifications

The expireAllNotifications method allows you to expire all notifications.

Notifier::expireAllNotifications();

Fetch Notifications

The fetchNotifications method allows you to fetch all notifications from the session.

Notifier::fetchNotifications();

Store Notifications

The storeNotifications method allows you to store all notifications into the session.

Notifier::storeNotifications();

To Array

The toArray method allows you convert an array of Notification objects to an array of arrays.

$notifications = Notifier::getNotifications();
Notifier::toArray($notifications);

License

Notifier is open-sourced software licensed under the MIT license

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-08-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固