ideas
ideas copied to clipboard
Ability to get event name which fires in Eloquent booted method
Looking for a way to get event name which fires in booted method in string.
Instead of :
protected static function booted()
{
static::updating(function (self $m) {
//same thing
});
static::updated(function (self $m) {
//same thing
});
}
I wish i could able to do this:
if (in_array($event = static::getEventName(), ['updating', 'updated'])) {
static::$event(function (self $m) {
//
});
}
this package is out of date but you can do like this https://github.com/RMoorePHP/change-recorder/blob/4dac6bc5771507e4f1bd6277d2a99d84da555275/src/RecordsChanges.php#L9-L13