adamthehutt / eloquent-constructed-event
此包已被弃用且不再维护。未建议替代包。
Eloquent 模型特性,用于添加一个 'constructed' 事件,该事件将在对象构造后立即触发
v1.3.0
2020-09-24 02:49 UTC
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 模型特性,用于添加一个 'constructed' 事件,该事件将在对象构造后立即触发
安装
composer require adamthehutt/eloquent-constructed-event
使用
将特性添加到 Eloquent 模型
class MyModel extends Model { use AdamTheHutt\EloquentConstructedEvent\HasConstructedEvent; }
在模型构造后执行有趣的事情
public static function boot() { static::registerModelEvent("constructed", function (MyModel $model) { $model->generateUuid(); $model->tellTheWorldIExist(); }); }