Add more API calls
This commit is contained in:
parent
189b2e9a01
commit
ae46f9068c
2 changed files with 44 additions and 6 deletions
|
|
@ -612,6 +612,49 @@ class APIController extends Controller
|
|||
if ($res->isError())
|
||||
return $res->getReturnResponse();
|
||||
|
||||
// get vehicle
|
||||
$vehicle = $em->getRepository(Vehicle::class)->find($vid);
|
||||
if ($vehicle == null)
|
||||
{
|
||||
$res->setError(true)
|
||||
->setErrorMessage('Invalid vehicle');
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
// batteries
|
||||
$batt_list = [];
|
||||
$batts = $vehicle->getBatteries();
|
||||
foreach ($batts as $batt)
|
||||
{
|
||||
$batt_list[] = [
|
||||
'id' => $batt->getID(),
|
||||
'mfg_id' => $batt->getManufacturer()->getID(),
|
||||
'mfg_name' => $batt->getManufacturer()->getName(),
|
||||
'model_id' => $batt->getModel()->getID(),
|
||||
'model_name' => $batt->getModel()->getName(),
|
||||
'size_id' => $batt->getSize()->getID(),
|
||||
'size_name' => $batt->getSize()->getName(),
|
||||
'price' => $batt->getSellingPrice(),
|
||||
'wty_personal' => $batt->getWarrantyPersonal(),
|
||||
'wty_commercial' => $batt->getWarrantyCommercial(),
|
||||
];
|
||||
}
|
||||
|
||||
// data
|
||||
$data = [
|
||||
'vehicle' => [
|
||||
'id' => $vehicle->getID(),
|
||||
'mfg_id' => $vehicle->getManufacturer()->getID(),
|
||||
'mfg_name' => $vehicle->getManufacturer()->getName(),
|
||||
'make' => $vehicle->getMake(),
|
||||
'model_year_from' => $vehicle->getModelYearFrom(),
|
||||
'model_year_to' => $vehicle->getModelYearTo(),
|
||||
],
|
||||
'batteries' => $batt_list,
|
||||
];
|
||||
$res->setData($data);
|
||||
|
||||
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -130,11 +130,6 @@ class Vehicle
|
|||
|
||||
public function getBatteries()
|
||||
{
|
||||
// has to return set of strings because symfony is trying to move away from role objects
|
||||
$str_batteries = [];
|
||||
foreach ($this->batteries as $battery)
|
||||
$str_batteries[] = $this->getProductCode();
|
||||
|
||||
return $str_batteries;
|
||||
return $this->batteries;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue