mirror of
https://github.com/grocy/grocy.git
synced 2026-03-27 23:29:25 +01:00
fix: products route
This commit is contained in:
parent
7d104d2384
commit
1f8596ccb9
|
|
@ -47,6 +47,16 @@ class GenericEntityApiController extends BaseApiController
|
||||||
throw new \Exception('Request body could not be parsed (probably invalid JSON format or missing/wrong Content-Type header)');
|
throw new \Exception('Request body could not be parsed (probably invalid JSON format or missing/wrong Content-Type header)');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($args['entity'] == 'products' && (!isset($requestBody['qu_id_purchase']) || empty($requestBody['qu_id_purchase'])))
|
||||||
|
{
|
||||||
|
return $this->GenericErrorResponse($response, 'Product does not have Quantity unit purchase defined');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($args['entity'] == 'products' && (!isset($requestBody['qu_id_stock']) || empty($requestBody['qu_id_stock'])))
|
||||||
|
{
|
||||||
|
return $this->GenericErrorResponse($response, 'Product does not have Quantity unit stock defined');
|
||||||
|
}
|
||||||
|
|
||||||
$newRow = $this->getDatabase()->{$args['entity']}()->createRow($requestBody);
|
$newRow = $this->getDatabase()->{$args['entity']}()->createRow($requestBody);
|
||||||
$newRow->save();
|
$newRow->save();
|
||||||
$newObjectId = $this->getDatabase()->lastInsertId();
|
$newObjectId = $this->getDatabase()->lastInsertId();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user