reallyli / laravel-event-store
Laravel event store
1.0.0
2019-11-08 03:56 UTC
Requires
- php: ^7.1
- illuminate/database: ^5.7|^6.0
- illuminate/support: ^5.7|^6.0
- ramsey/uuid: 3.8.0
This package is auto-updated.
Last update: 2024-11-08 16:11:14 UTC
README
1. Setup dependency
composer require tlikai/laravel-event-store
2. Setup database
php artisan migrate
3. Implementation ShouldBeStored
interface
use App\User; use Uniqueway\LaravelEventStore\ShouldBeStored; class UserCreated implements ShouldBeStored { public $user; public function __construct(User $user) { $this->user = $user; } // return stored event data public function getData() { return [ 'user_id' => $this->user->id, ]; } }
4. Fire events
$user = User::create(['name' => 'likai']) event(new UserCreated($user));