model = new UserModel(); } public function __invoke(ServerRequestInterface $request) { $body = json_decode((string)$request->getBody(), true) ?? []; if (!isset($body['company_id']) || !is_numeric($body['company_id']) || (int)$body['company_id'] <= 0) { return ResponseLib::sendFail("Validation failed: invalid company_id", [], "E_VALIDATE")->withStatus(400); } $companyId = (int) $body['company_id']; $users = $this->model->getUsersByCompany($companyId); return $users ? ResponseLib::sendOk($users) : ResponseLib::sendFail("User Not Found", [], "E_DATABASE")->withStatus(204); } }