Skip to content
This repository has been archived by the owner on Jul 16, 2021. It is now read-only.

Ability to get event name which fires in Eloquent booted method #2656

Open
foremtehan opened this issue Jun 30, 2021 · 1 comment
Open

Ability to get event name which fires in Eloquent booted method #2656

foremtehan opened this issue Jun 30, 2021 · 1 comment

Comments

@foremtehan
Copy link

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) {
        //
    });
}
@rs-sliske
Copy link

rs-sliske commented Jul 1, 2021

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants