composer require tlikai/laravel-event-store
php artisan migrate
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,
];
}
}
$user = User::create(['name' => 'likai'])
event(new UserCreated($user));