Open-source event management and ticket selling platform — perfect for concerts, conferences, and everything in between 🎟️ If you find this project helpful, please consider giving us a star ⭐️
PHP attendize-alternativedoor-managementevent-check-inevent-managementevent-registrationevent-ticketingeventbrite-alternativeeventslaravelopen-sourcephpreactself-hostedsell-ticketssell-tickets-onlineticket-sellingticketing-systemtickettailor-alternativetito-alternative
Fix webhook causing some checkouts to fail (#464)
Dave Earley7f5b8025939a
diff --git a/backend/app/Repository/Eloquent/BaseRepository.php b/backend/app/Repository/Eloquent/BaseRepository.phpindex 0a3364b71..aa174bd99 100644--- a/backend/app/Repository/Eloquent/BaseRepository.php+++ b/backend/app/Repository/Eloquent/BaseRepository.php@@ -62,7 +62,10 @@ abstract class BaseRepository implements RepositoryInterfacepublic function all(array $columns = self::DEFAULT_COLUMNS): Collection{- return $this->handleResults($this->model->all($columns));+ $models = $this->model->all($columns);+ $this->resetModel();++ return $this->handleResults($models);}public function paginate(@@ -121,7 +124,10 @@ abstract class BaseRepository implements RepositoryInterface*/public function findById(int $id, array $columns = self::DEFAULT_COLUMNS): DomainObjectInterface{- return $this->handleSingleResult($this->model->findOrFail($id, $columns));+ $model = $this->model->findOrFail($id, $columns);+ $this->resetModel();++ return $this->handleSingleResult($model);}public function findFirstByField(@@ -138,7 +144,10 @@ abstract class BaseRepository implements RepositoryInterfacepublic function findFirst(int $id, array $columns = self::DEFAULT_COLUMNS): ?DomainObjectInterface{- return $this->handleSingleResult($this->model->findOrFail($id, $columns));+ $model = $this->model->findOrFail($id, $columns);+ $this->resetModel();++ return $this->handleSingleResult($model);}public function findWhere(diff --git a/backend/app/Services/Application/Handlers/Order/CompleteOrderHandler.php b/backend/app/Services/Application/Handlers/Order/CompleteOrderHandler.phpindex 1604f253e..bfeb1b587 100644--- a/backend/app/Services/Application/Handlers/Order/CompleteOrderHandler.php+++ b/backend/app/Services/Application/Handlers/Order/CompleteOrderHandler.php@@ -62,7 +62,7 @@ class CompleteOrderHandler*/public function handle(string $orderShortId, CompleteOrderDTO $orderData): OrderDomainObject{- return DB::transaction(function () use ($orderData, $orderShortId) {+ $updatedOrder = DB::transaction(function () use ($orderData, $orderShortId) {$orderDTO = $orderData->order;$order = $this->getOrder($orderShortId);@@ -85,19 +85,21 @@ class CompleteOrderHandler$this->productQuantityUpdateService->updateQuantitiesFromOrder($updatedOrder);}- OrderStatusChangedEvent::dispatch($updatedOrder);-- if ($updatedOrder->isOrderCompleted()) {- $this->domainEventDispatcherService->dispatch(- new OrderEvent(- type: DomainEventType::ORDER_CREATED,- orderId: $updatedOrder->getId(),- )- );- }-return $updatedOrder;});++ OrderStatusChangedEvent::dispatch($updatedOrder);++ if ($updatedOrder->isOrderCompleted()) {+ $this->domainEventDispatcherService->dispatch(+ new OrderEvent(+ type: DomainEventType::ORDER_CREATED,+ orderId: $updatedOrder->getId(),+ )+ );+ }++ return $updatedOrder;}/**diff --git a/backend/app/Services/Infrastructure/DomainEvents/DomainEventDispatcherService.php b/backend/app/Services/Infrastructure/DomainEvents/DomainEventDispatcherService.phpindex 5c833d861..e40847cd3 100644--- a/backend/app/Services/Infrastructure/DomainEvents/DomainEventDispatcherService.php+++ b/backend/app/Services/Infrastructure/DomainEvents/DomainEventDispatcherService.php@@ -4,15 +4,29 @@ namespace HiEvents\Services\Infrastructure\DomainEvents;use HiEvents\Services\Infrastructure\DomainEvents\Events\BaseDomainEvent;use Illuminate\Events\Dispatcher as EventDispatcher;+use Psr\Log\LoggerInterface;+use Throwable;class DomainEventDispatcherService{- public function __construct(private readonly EventDispatcher $dispatcher)+ public function __construct(+ private readonly EventDispatcher $dispatcher,+ private readonly LoggerInterface $logger,+ ){}+ /**+ * @throws Throwable+ */public function dispatch(BaseDomainEvent $event): void{- $this->dispatcher->dispatch($event);+ try {+ $this->dispatcher->dispatch($event);+ } catch (Throwable $e) {+ $this->logger->error('Failed to dispatch domain event', ['event' => $event, 'exception' => $e]);++ throw $e;+ }}}