Skip to content

Commit

Permalink
Merge pull request #476 from maartenpaauw/fix/use-class-map-name-when…
Browse files Browse the repository at this point in the history
…-querying-event-class

Use class map name when querying event class
  • Loading branch information
sebastiandedeyne authored Oct 10, 2024
2 parents b7a0422 + a572071 commit 4ef1bb7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/StoredEvents/Models/EloquentStoredEventQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace Spatie\EventSourcing\StoredEvents\Models;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Arr;
use Spatie\EventSourcing\StoredEvents\StoredEvent;

/**
* @method \Spatie\EventSourcing\StoredEvents\Models\EloquentStoredEventCollection get
Expand Down Expand Up @@ -32,7 +34,10 @@ public function whereAggregateRoot(string $uuid): self

public function whereEvent(string ...$eventClasses): self
{
$this->whereIn('event_class', $eventClasses);
$this->whereIn('event_class', array_map(
fn (string $eventClass): string => StoredEvent::getEventClass($eventClass),
$eventClasses,
));

return $this;
}
Expand Down
2 changes: 1 addition & 1 deletion src/StoredEvents/StoredEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ protected static function getActualClassForEvent(string $class): string
return Arr::get(config('event-sourcing.event_class_map', []), $class, $class);
}

protected static function getEventClass(string $class): string
public static function getEventClass(string $class): string
{
$map = config('event-sourcing.event_class_map', []);

Expand Down

0 comments on commit 4ef1bb7

Please sign in to comment.