adamthehutt/eloquent-constructed-event

This package is abandoned and no longer maintained. No replacement package was suggested.

Eloquent model trait to add a 'constructed' event, which will fire immediately after object construction

Installs: 1 823

Dependents: 2

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/adamthehutt/eloquent-constructed-event

v1.3.0 2020-09-24 02:49 UTC

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();
    });
}