tlikai / laravel-event-store
Laravel event store
Installs: 2 251
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 3
Open Issues: 0
Requires
- php: ^7.1
- illuminate/database: 5.7.*
- illuminate/support: 5.7.*
- ramsey/uuid: 3.8.0
This package is not auto-updated.
Last update: 2024-12-28 00:01:08 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));