Skip to content
This repository was archived by the owner on Jul 16, 2021. It is now read-only.
This repository was 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

Description

@foremtehan

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) {
        //
    });
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions