Facades
We offer facades for easy access to event sourcing services. You can use the facades to access the repositories, the store or manage your aggregates. This feature is optional, you can still use the services directly via dependency injection.
Aggregate
If your aggregates extend the laravel package provided AggregateRoot class,
you can use the helper methods to load and save your aggregates.
use Patchlevel\EventSourcing\Attribute\Aggregate;
use Patchlevel\LaravelEventSourcing\AggregateRoot;
#[Aggregate(name: 'hotel')]
final class Hotel extends AggregateRoot
{
// ...
}
load method of your specific aggregate class you can load your aggregates.
And save them by using the save method on the aggregate instance.
Repository
You can access the specific repositories using the get method of the Repository facade.
Store
You can access the store using the Store facade.
There you can save multiple messages at once:
use Patchlevel\EventSourcing\Store\Criteria\AggregateIdCriterion;
use Patchlevel\EventSourcing\Store\Criteria\Criteria;
use Patchlevel\LaravelEventSourcing\Facade\Store;
$messages = Store::load(
new Criteria(
new AggregateIdCriterion('123'),
),
);
Note
This documentation is limited to the package integration. You should also read the library documentation.