adamthehutt / eloquent-constructed-event
Eloquent model trait to add a 'constructed' event, which will fire immediately after object construction
Installs: 1 662
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Requires
- illuminate/database: ^5.8 | ^6.0 | ^7.0 | ^8.0
- illuminate/support: ^5.8 | ^6.0 | ^7.0 | ^8.0
Requires (Dev)
- orchestra/testbench: ^3.8 | ^4.0
- phpunit/phpunit: ^8.2
This package is auto-updated.
Last update: 2022-01-10 20:30:27 UTC
README
Eloquent model trait to add a 'constructed' event, which will fire immediately after object construction
Install
composer require adamthehutt/eloquent-constructed-event
Use
Add the trait to an Eloquent model:
class MyModel extends Model { use AdamTheHutt\EloquentConstructedEvent\HasConstructedEvent; }
Do interesting things after model construction:
public static function boot() { static::registerModelEvent("constructed", function (MyModel $model) { $model->generateUuid(); $model->tellTheWorldIExist(); }); }