Skip to content

uniqueway/laravel-event-store

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LaravelEventStore

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

Inspired by

About

Laravel event store, persist your events

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%