model = new DiscountModel(); } public function __invoke(ServerRequestInterface $request) { try { $rows = $this->model->getAll(); } catch (\Throwable $e) { return ResponseLib::sendFail('Failed to fetch discounts: ' . $e->getMessage(), [], 'E_DATABASE')->withStatus(500); } if (!$rows) { return ResponseLib::sendFail('Discounts Not Found', [], 'E_DATABASE')->withStatus(204); } return ResponseLib::sendOk($rows, 'S_DISCOUNTS'); } }