|
@@ -20,10 +20,10 @@ class OrderItemUpdateController
|
|
|
public function __invoke(ServerRequestInterface $request)
|
|
public function __invoke(ServerRequestInterface $request)
|
|
|
{
|
|
{
|
|
|
$body = json_decode((string)$request->getBody(), true) ?? [];
|
|
$body = json_decode((string)$request->getBody(), true) ?? [];
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
try {
|
|
try {
|
|
|
v::key('company_id', v::intType()->positive())
|
|
v::key('company_id', v::intType()->positive())
|
|
|
- ->key('order_item_id', v::intType()->positive())
|
|
|
|
|
|
|
+ ->key('order_item_ids', v::arrayType()->each(v::intType()->positive()))
|
|
|
->assert($body);
|
|
->assert($body);
|
|
|
} catch (ValidationException $e) {
|
|
} catch (ValidationException $e) {
|
|
|
return ResponseLib::sendFail(
|
|
return ResponseLib::sendFail(
|
|
@@ -32,14 +32,14 @@ class OrderItemUpdateController
|
|
|
"E_VALIDATE"
|
|
"E_VALIDATE"
|
|
|
)->withStatus(400);
|
|
)->withStatus(400);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$companyId = (int) $body['company_id'];
|
|
$companyId = (int) $body['company_id'];
|
|
|
- $orderItemId = (int) $body['order_item_id'];
|
|
|
|
|
-
|
|
|
|
|
- $updated = $this->model->updateOrderItem($orderItemId, $companyId);
|
|
|
|
|
-
|
|
|
|
|
- return $updated
|
|
|
|
|
- ? ResponseLib::sendOk(['updated' => true])
|
|
|
|
|
- : ResponseLib::sendFail("Failed to Update Order Item Flag", [], "E_DATABASE")->withStatus(500);
|
|
|
|
|
|
|
+ $orderItemIds = $body['order_item_ids'];
|
|
|
|
|
+
|
|
|
|
|
+ $results = $this->model->updateOrderItems($orderItemIds, $companyId);
|
|
|
|
|
+
|
|
|
|
|
+ return ResponseLib::sendOk([
|
|
|
|
|
+ 'updated_items' => $results
|
|
|
|
|
+ ]);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|