model = new KitchenModel(); } public function __invoke(ServerRequestInterface $request) { $body = json_decode((string) $request->getBody(), true) ?? []; try { v::key('company_id', v::intType()->positive())->assert($body); } catch (ValidationException $e) { return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(401); } $companyId = (int) $body['company_id']; $orders = $this->model->getKitchenOrders($companyId); if (!$orders) { return ResponseLib::sendFail("No kitchen orders found", [], "E_NO_DATA")->withStatus(204); } return ResponseLib::sendOk($orders); } }