|
@@ -15,18 +15,20 @@ class DescriptionUpdateController
|
|
|
$body = json_decode((string) $request->getBody(), true) ?? [];
|
|
$body = json_decode((string) $request->getBody(), true) ?? [];
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- v::key('description_id', v::intType()->positive())
|
|
|
|
|
|
|
+ v::key('product_id', v::intType()->positive())
|
|
|
|
|
+ ->key('company_id', v::intType()->positive())
|
|
|
->key('description_text', v::stringType()->notEmpty())
|
|
->key('description_text', v::stringType()->notEmpty())
|
|
|
->assert($body);
|
|
->assert($body);
|
|
|
} catch (ValidationException $e) {
|
|
} catch (ValidationException $e) {
|
|
|
return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(400);
|
|
return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(400);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $descriptionId = (int) $body['description_id'];
|
|
|
|
|
|
|
+ $productId = (int) $body['product_id'];
|
|
|
|
|
+ $companyId = (int) $body['company_id'];
|
|
|
$descriptionText = (string) $body['description_text'];
|
|
$descriptionText = (string) $body['description_text'];
|
|
|
|
|
|
|
|
$model = new DescriptionModel();
|
|
$model = new DescriptionModel();
|
|
|
- $success = $model->updateDescription($descriptionId, $descriptionText);
|
|
|
|
|
|
|
+ $success = $model->updateDescription($productId, $companyId, $descriptionText);
|
|
|
|
|
|
|
|
return $success
|
|
return $success
|
|
|
? ResponseLib::sendOk(['updated' => true])
|
|
? ResponseLib::sendOk(['updated' => true])
|