Looking to hire Laravel developers? Try LaraJobs

laravel-event-recorder maintained by slavcodev

Description
Laravel Eloquent event recorder
Last update
2024/03/30 01:32 (dev-main)
License
Links
Downloads
1 999

Comments
comments powered by Disqus

Laravel Eloquent event recorder

phpunit psalm php-cs-fixer Latest Version License License

Event recorder trait useful when an event should be emitted only after model successfully saved.

Installation

Using Composer

composer require slavcodev/laravel-event-recorder

Usage

Just add the trait to any of you Eloquent model, it adds recordEvent($event) method and registers listener to emit all recorded events after save.

class User extends \Illuminate\Database\Eloquent\Model
{
    use \Slavcodev\Laravel\Events\EventRecorder;
    
    public function someModifications()
    {
        $this->recordEvent(new UserChanged());
    }
}

Testing

phpunit

Contributing

Please see CONTRIBUTING and CODE OF CONDUCT for more details.