承接 envant/fireable 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

envant/fireable

最新稳定版本:v1.0.11

Composer 安装命令:

composer require envant/fireable

包简介

An elegant way to trigger events based on attributes changes

README 文档

README

Latest Version on Packagist StyleCI Build Status Total Downloads

An elegant way to trigger events based on attributes changes.

Installation

Install package through Composer

$ composer require envant/fireable

Usage

  1. Add the FireableAttributes trait to your model
  2. Define the attributes with specified events via the protected $fireableAttributes property on the model

Example

Let's say we need to trigger specified events when specific model attributes are updated.

For example, you need to notify user when he gets an "approved" status. Instead of observing model's "dirty" attributes and firing events manually we could do it more elegantly by assigning specified events to attributes or even certain values of attributes.

class User extends Authenticatable
{
    use FireableAttributes;

    protected $fireableAttributes = [
        'status' => [
            'approved' => UserApproved::class,
            'rejected' => UserRejected::class,
        ],
    ];
}

Also you may not need to track certain values, so you can assign an event directly to an attribute itself. So, in the example below, each time the user's email is changed, the appropriate event will be fired.

class User extends Authenticatable
{
    use FireableAttributes;

    protected $fireableAttributes = [
        'email' => EmailUpdated::class,
    ];
}

Change log

Please see the changelog for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see contributing.md for details and a todolist.

Security

If you discover any security related issues, please email author email instead of using the issue tracker.

Credits

License

license. Please see the license file for more information.

统计信息

  • 总下载量: 784.31k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 448
  • 点击次数: 1
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 445
  • Watchers: 8
  • Forks: 26
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-09-18