Skip to content

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 ⭐️

Fix order update request not using event ID in update (#473)

Dave Earleyb8c5cfa978d5
diff --git a/backend/app/Http/Actions/Orders/EditOrderAction.php b/backend/app/Http/Actions/Orders/EditOrderAction.php
index 9153255c8..ba919daf0 100644
--- a/backend/app/Http/Actions/Orders/EditOrderAction.php
+++ b/backend/app/Http/Actions/Orders/EditOrderAction.php
@@ -24,8 +24,9 @@ class EditOrderAction extends BaseAction
$order = $this->handler->handle(new EditOrderDTO(
id: $orderId,
- first_name: $request->validated('first_name'),
- last_name: $request->validated('last_name'),
+ eventId: $eventId,
+ firstName: $request->validated('first_name'),
+ lastName: $request->validated('last_name'),
email: $request->validated('email'),
notes: $request->validated('notes'),
));
diff --git a/backend/app/Services/Application/Handlers/Order/DTO/EditOrderDTO.php b/backend/app/Services/Application/Handlers/Order/DTO/EditOrderDTO.php
index d9a25aa63..e53b980aa 100644
--- a/backend/app/Services/Application/Handlers/Order/DTO/EditOrderDTO.php
+++ b/backend/app/Services/Application/Handlers/Order/DTO/EditOrderDTO.php
@@ -7,10 +7,11 @@ use HiEvents\DataTransferObjects\BaseDTO;
class EditOrderDTO extends BaseDTO
{
public function __construct(
- public int $id,
- public string $first_name,
- public string $last_name,
- public string $email,
+ public int $id,
+ public int $eventId,
+ public string $firstName,
+ public string $lastName,
+ public string $email,
public ?string $notes,
)
{
diff --git a/backend/app/Services/Application/Handlers/Order/EditOrderHandler.php b/backend/app/Services/Application/Handlers/Order/EditOrderHandler.php
index 450700665..9279ba013 100644
--- a/backend/app/Services/Application/Handlers/Order/EditOrderHandler.php
+++ b/backend/app/Services/Application/Handlers/Order/EditOrderHandler.php
@@ -28,8 +28,9 @@ class EditOrderHandler
return $this->editOrderService->editOrder(
id: $dto->id,
- first_name: $dto->first_name,
- last_name: $dto->last_name,
+ eventId: $dto->eventId,
+ firstName: $dto->firstName,
+ lastName: $dto->lastName,
email: $dto->email,
notes: $dto->notes
);
diff --git a/backend/app/Services/Domain/Order/EditOrderService.php b/backend/app/Services/Domain/Order/EditOrderService.php
index 186b73dba..81af767d6 100644
--- a/backend/app/Services/Domain/Order/EditOrderService.php
+++ b/backend/app/Services/Domain/Order/EditOrderService.php
@@ -25,22 +25,24 @@ class EditOrderService
*/
public function editOrder(
int $id,
- ?string $first_name,
- ?string $last_name,
+ int $eventId,
+ ?string $firstName,
+ ?string $lastName,
?string $email,
?string $notes
): OrderDomainObject
{
- return $this->databaseManager->transaction(function () use ($id, $first_name, $last_name, $email, $notes) {
+ return $this->databaseManager->transaction(function () use ($id, $firstName, $lastName, $email, $notes, $eventId) {
$this->orderRepository->updateWhere(
attributes: array_filter([
- 'first_name' => $first_name,
- 'last_name' => $last_name,
+ 'first_name' => $firstName,
+ 'last_name' => $lastName,
'email' => $email,
'notes' => $notes,
]),
where: [
- 'id' => $id
+ 'id' => $id,
+ 'event_id' => $eventId,
]
);
@@ -51,7 +53,10 @@ class EditOrderService
),
);
- return $this->orderRepository->findById($id);
+ return $this->orderRepository->findFirstWhere([
+ 'id' => $id,
+ 'event_id' => $eventId,
+ ]);
});
}
}