model = new CategoryModel(); } public function __invoke(ServerRequestInterface $request) { $body = json_decode((string)$request->getBody(), true) ?? []; $companyId = $body['company_id'] ?? null; $added = $this->model->addProductToCategory( $body['product_name'], $body['product_price'], $body['category_name'], $companyId ); return $added ? ResponseLib::sendOk(['product_added' => true]) : ResponseLib::sendFail("Category Not Found", [], "E_VALIDATE")->withStatus(404); } }