Skip to content

Commit b8c5cfa

Browse files
authored
Fix order update request not using event ID in update (#473)
1 parent 5895eda commit b8c5cfa

File tree

4 files changed

+23
-15
lines changed

4 files changed

+23
-15
lines changed

backend/app/Http/Actions/Orders/EditOrderAction.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ public function __invoke(EditOrderRequest $request, int $eventId, int $orderId):
2424

2525
$order = $this->handler->handle(new EditOrderDTO(
2626
id: $orderId,
27-
first_name: $request->validated('first_name'),
28-
last_name: $request->validated('last_name'),
27+
eventId: $eventId,
28+
firstName: $request->validated('first_name'),
29+
lastName: $request->validated('last_name'),
2930
email: $request->validated('email'),
3031
notes: $request->validated('notes'),
3132
));

backend/app/Services/Application/Handlers/Order/DTO/EditOrderDTO.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
class EditOrderDTO extends BaseDTO
88
{
99
public function __construct(
10-
public int $id,
11-
public string $first_name,
12-
public string $last_name,
13-
public string $email,
10+
public int $id,
11+
public int $eventId,
12+
public string $firstName,
13+
public string $lastName,
14+
public string $email,
1415
public ?string $notes,
1516
)
1617
{

backend/app/Services/Application/Handlers/Order/EditOrderHandler.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ public function handle(EditOrderDTO $dto): OrderDomainObject
2828

2929
return $this->editOrderService->editOrder(
3030
id: $dto->id,
31-
first_name: $dto->first_name,
32-
last_name: $dto->last_name,
31+
eventId: $dto->eventId,
32+
firstName: $dto->firstName,
33+
lastName: $dto->lastName,
3334
email: $dto->email,
3435
notes: $dto->notes
3536
);

backend/app/Services/Domain/Order/EditOrderService.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,24 @@ public function __construct(
2525
*/
2626
public function editOrder(
2727
int $id,
28-
?string $first_name,
29-
?string $last_name,
28+
int $eventId,
29+
?string $firstName,
30+
?string $lastName,
3031
?string $email,
3132
?string $notes
3233
): OrderDomainObject
3334
{
34-
return $this->databaseManager->transaction(function () use ($id, $first_name, $last_name, $email, $notes) {
35+
return $this->databaseManager->transaction(function () use ($id, $firstName, $lastName, $email, $notes, $eventId) {
3536
$this->orderRepository->updateWhere(
3637
attributes: array_filter([
37-
'first_name' => $first_name,
38-
'last_name' => $last_name,
38+
'first_name' => $firstName,
39+
'last_name' => $lastName,
3940
'email' => $email,
4041
'notes' => $notes,
4142
]),
4243
where: [
43-
'id' => $id
44+
'id' => $id,
45+
'event_id' => $eventId,
4446
]
4547
);
4648

@@ -51,7 +53,10 @@ public function editOrder(
5153
),
5254
);
5355

54-
return $this->orderRepository->findById($id);
56+
return $this->orderRepository->findFirstWhere([
57+
'id' => $id,
58+
'event_id' => $eventId,
59+
]);
5560
});
5661
}
5762
}

0 commit comments

Comments
 (0)