envant/fireable
소개
속성 변경에 따라 Laravel 이벤트를 발생시키는 간결한 방법입니다.
웹 및 앱 개발측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalFireable
An elegant way to trigger events based on attributes changes.
Installation
Install package through Composer
$ composer require envant/fireable
Usage
- Add the
FireableAttributestrait to your model - Define the attributes with specified events via the
protected $fireableAttributesproperty 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.
관련 프로젝트 살펴보기
불러오는 중…