cornford/alerter

一种简单管理用户警报的方法,提供各种警报选项以加速用户警报。

v2.1.0 2016-06-15 08:56 UTC

This package is auto-updated.

Last update: 2024-09-07 06:18:36 UTC


README

Latest Stable Version Total Downloads Build Status Scrutinizer Code Quality

对于Laravel 4.x,请查看版本1.0.0

将Alerter视为一种简单管理用户警报的方法,提供各种警报选项以加速用户警报。这些包括

  • Alert::create
  • Alert::error
  • Alert::info
  • Alert::warning
  • Alert::success
  • Alert::none

它附带了一些最流行的CSS框架的模板预构建。这些包括

  • Bootstrap
  • Foundation
  • Pure

它还可以完全自定义,允许创建新的模板,以及新的警报类型。

安装

首先,通过Composer安装此包。编辑项目中的composer.json文件,以要求cornford/alerter

"require-dev": {
	"cornford/alerter": "2.*"
}

接下来,在终端中更新Composer

composer update --dev

此操作完成后,最后一步是添加服务提供者。打开app/config/app.php,向提供者数组添加一个新项。

'Cornford\Alerter\AlerterServiceProvider'

就这样!你已经准备好了。

使用方法

使用Alerter类在任意的Controller / Model / 文件中都是非常简单的

use Cornford\Alerter\Alert;

这将为您打开以下访问权限

创建

create方法允许您创建一个具有预构建类型的新警报,或指定自己的类型。

Alert::create(Alert::TYPE_ERROR, 'This is an error message!')->display();
Alert::create('Custom', 'This is a custom message!')->display();

typecontent选项都是必需的。

错误

error方法允许您创建一个不指定类型的新警报错误。

Alert::error('This is an error message!')->display();

content选项是必需的。

信息

info方法允许您创建一个不指定类型的新警报信息。

Alert::info('This is an info message!')->display();

content选项是必需的。

警告

warning方法允许您创建一个不指定类型的新警报警告。

Alert::warning('This is a warning message!')->display();

content选项是必需的。

成功

success方法允许您创建一个不指定类型的新警报成功。

Alert::Success('This is a success message!')->display();

content选项是必需的。

none方法允许您创建一个不指定类型的新警报无。

Alert::None('This is a none message!')->display();

content选项是必需的。

许可证

Alerter是开源软件,许可协议为MIT许可证