|
|
@@ -33,7 +33,7 @@ class OrderCreateController
|
|
|
->key('status_status', v::stringType()->notEmpty()->in(['Aberta', 'Finalizada', 'Cancelada']))
|
|
|
->assert($body);
|
|
|
} catch (ValidationException $e) {
|
|
|
- return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(400);
|
|
|
+ return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(422);
|
|
|
}
|
|
|
|
|
|
$tableId = (int) $body['table_id'];
|
|
|
@@ -47,13 +47,13 @@ class OrderCreateController
|
|
|
$userId = $this->getUserIdByUserName($userName, $companyId);
|
|
|
|
|
|
if (!$userId) {
|
|
|
- return ResponseLib::sendFail("Usuário '{$userName}' não encontrado", [], "E_USER_NOT_FOUND")->withStatus(404);
|
|
|
+ return ResponseLib::sendFail("User '{$userName}' Not Found", [], "E_USER_NOT_FOUND")->withStatus(404);
|
|
|
}
|
|
|
|
|
|
$statusId = $this->model->getStatusIdByName($statusStatus);
|
|
|
|
|
|
if ($statusId === null) {
|
|
|
- return ResponseLib::sendFail("Invalid status_status provided: '{$statusStatus}'", [], "E_VALIDATE")->withStatus(400);
|
|
|
+ return ResponseLib::sendFail("Invalid status_status Provided: '{$statusStatus}'", [], "E_VALIDATE")->withStatus(400);
|
|
|
}
|
|
|
|
|
|
$created = $this->model->createOrder(
|
|
|
@@ -67,7 +67,7 @@ class OrderCreateController
|
|
|
|
|
|
return $created
|
|
|
? ResponseLib::sendOk(['created' => true, 'order_id' => $created])
|
|
|
- : ResponseLib::sendFail("Failed to create order", [], "E_DATABASE")->withStatus(500);
|
|
|
+ : ResponseLib::sendFail("Failed to Create Order", [], "E_DATABASE")->withStatus(500);
|
|
|
}
|
|
|
|
|
|
private function getUserIdByUserName(string $username, int $companyId): ?int
|