Package Data | |
---|---|
Maintainer Username: | lepikhinb |
Maintainer Contact: | info@envant.me (Boris Lepikhin) |
Package Create Date: | 2019-09-18 |
Package Last Update: | 2024-03-01 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-23 03:21:57 |
Package Statistics | |
---|---|
Total Downloads: | 593,345 |
Monthly Downloads: | 14,828 |
Daily Downloads: | 80 |
Total Stars: | 448 |
Total Watchers: | 9 |
Total Forks: | 23 |
Total Open Issues: | 3 |
An elegant way to trigger events based on attributes changes.
Install package through Composer
$ composer require envant/fireable
FireableAttributes
trait to your modelprotected $fireableAttributes
property on the modelLet'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,
];
}
Please see the changelog for more information on what has changed recently.
$ composer test
Please see contributing.md for details and a todolist.
If you discover any security related issues, please email author email instead of using the issue tracker.
license. Please see the license file for more information.