Change brand and size parameters to brand_id and size_id. #201
This commit is contained in:
parent
620a750465
commit
24a0e5a2d1
2 changed files with 10 additions and 10 deletions
|
|
@ -77,12 +77,12 @@ class TestCommand extends Command
|
||||||
|
|
||||||
// add battery
|
// add battery
|
||||||
$sku = 'WZMB31QT-CPP00-S';
|
$sku = 'WZMB31QT-CPP00-S';
|
||||||
$brand = '4';
|
$brand_id = '4';
|
||||||
$size = '1';
|
$size_id = '1';
|
||||||
$params = [
|
$params = [
|
||||||
'sku' => $sku,
|
'sku' => $sku,
|
||||||
'brand' => $brand,
|
'brand_id' => $brand_id,
|
||||||
'size' => $size,
|
'size_id' => $size_id,
|
||||||
];
|
];
|
||||||
$api->post('/capi/batteries', $params);
|
$api->post('/capi/batteries', $params);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -81,8 +81,8 @@ class BatteryController extends APIController
|
||||||
// required parameters
|
// required parameters
|
||||||
$params = [
|
$params = [
|
||||||
'sku',
|
'sku',
|
||||||
'brand',
|
'brand_id',
|
||||||
'size',
|
'size_id',
|
||||||
];
|
];
|
||||||
|
|
||||||
$msg = $this->checkRequiredParameters($req, $params);
|
$msg = $this->checkRequiredParameters($req, $params);
|
||||||
|
|
@ -91,8 +91,8 @@ class BatteryController extends APIController
|
||||||
return new APIResponse(false, $msg);
|
return new APIResponse(false, $msg);
|
||||||
|
|
||||||
$sku = $req->request->get('sku');
|
$sku = $req->request->get('sku');
|
||||||
$brand = $req->request->get('brand');
|
$brand_id = $req->request->get('brand_id');
|
||||||
$size = $req->request->get('size');
|
$size_id = $req->request->get('size_id');
|
||||||
|
|
||||||
// check if sku already exists
|
// check if sku already exists
|
||||||
$batt = $em->getRepository(SAPBattery::class)->find($sku);
|
$batt = $em->getRepository(SAPBattery::class)->find($sku);
|
||||||
|
|
@ -100,12 +100,12 @@ class BatteryController extends APIController
|
||||||
return new APIResponse(false, 'Battery SKU already exists.');
|
return new APIResponse(false, 'Battery SKU already exists.');
|
||||||
|
|
||||||
// check if brand exists
|
// check if brand exists
|
||||||
$batt_brand = $em->getRepository(SAPBatteryBrand::class)->find($brand);
|
$batt_brand = $em->getRepository(SAPBatteryBrand::class)->find($brand_id);
|
||||||
if ($batt_brand == null)
|
if ($batt_brand == null)
|
||||||
return new APIResponse(false, 'Invalid brand.');
|
return new APIResponse(false, 'Invalid brand.');
|
||||||
|
|
||||||
// check if size exists
|
// check if size exists
|
||||||
$batt_size = $em->getRepository(SAPBatterySize::class)->find($size);
|
$batt_size = $em->getRepository(SAPBatterySize::class)->find($size_id);
|
||||||
if ($batt_size == null)
|
if ($batt_size == null)
|
||||||
return new APIResponse(false, 'Invalid size.');
|
return new APIResponse(false, 'Invalid size.');
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue