Add null checks and set to '' for json data #247 #1102
1 changed files with 8 additions and 5 deletions
|
|
@ -701,11 +701,11 @@ class APIController extends Controller
|
||||||
$cvs = $cust->getVehicles();
|
$cvs = $cust->getVehicles();
|
||||||
foreach ($cvs as $cv)
|
foreach ($cvs as $cv)
|
||||||
{
|
{
|
||||||
$battery_id = null;
|
$battery_id = '';
|
||||||
if ($cv->getCurrentBattery() != null)
|
if ($cv->getCurrentBattery() != null)
|
||||||
$battery_id = $cv->getCurrentBattery()->getID();
|
$battery_id = $cv->getCurrentBattery()->getID();
|
||||||
|
|
||||||
$wty_ex = null;
|
$wty_ex = '';
|
||||||
if ($cv->getWarrantyExpiration() != null)
|
if ($cv->getWarrantyExpiration() != null)
|
||||||
$wty_ex = $cv->getWarrantyExpiration()->format('Y-m-d');
|
$wty_ex = $cv->getWarrantyExpiration()->format('Y-m-d');
|
||||||
|
|
||||||
|
|
@ -721,7 +721,7 @@ class APIController extends Controller
|
||||||
'color' => $cv->getColor(),
|
'color' => $cv->getColor(),
|
||||||
'condition' => $cv->getStatusCondition(),
|
'condition' => $cv->getStatusCondition(),
|
||||||
'fuel_type' => $cv->getFuelType(),
|
'fuel_type' => $cv->getFuelType(),
|
||||||
'wty_code' => $cv->getWarrantyCode(),
|
'wty_code' => $cv->getWarrantyCode() ?? $cv->getWarrantyCode() : '',
|
||||||
'wty_expire' => $wty_ex,
|
'wty_expire' => $wty_ex,
|
||||||
'curr_batt_id' => $battery_id,
|
'curr_batt_id' => $battery_id,
|
||||||
'is_motolite' => $cv->hasMotoliteBattery() ? 1 : 0,
|
'is_motolite' => $cv->hasMotoliteBattery() ? 1 : 0,
|
||||||
|
|
@ -1950,12 +1950,15 @@ class APIController extends Controller
|
||||||
if (!(is_null($warranty->getBatteryModel()))) {
|
if (!(is_null($warranty->getBatteryModel()))) {
|
||||||
$batt_model = $warranty->getBatteryModel()->getName();
|
$batt_model = $warranty->getBatteryModel()->getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(is_null($warranty->getBatterySize()))) {
|
if (!(is_null($warranty->getBatterySize()))) {
|
||||||
$batt_size = $warranty->getBatterySize()->getName();
|
$batt_size = $warranty->getBatterySize()->getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(is_null($warranty->getSAPBattery()))) {
|
if (!(is_null($warranty->getSAPBattery()))) {
|
||||||
$sap_batt = $warranty->getSAPBattery()->getID();
|
$sap_batt = $warranty->getSAPBattery()->getID();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(is_null($warranty->getDateClaim()))) {
|
if (!(is_null($warranty->getDateClaim()))) {
|
||||||
$claim_date = $warranty->getDateClaim()->format("d M Y");
|
$claim_date = $warranty->getDateClaim()->format("d M Y");
|
||||||
}
|
}
|
||||||
|
|
@ -1965,7 +1968,7 @@ class APIController extends Controller
|
||||||
|
|
||||||
$warr[] = [
|
$warr[] = [
|
||||||
'id' => $warranty->getID(),
|
'id' => $warranty->getID(),
|
||||||
'serial' => $warranty->getSerial(),
|
'serial' => $warranty->getSerial() ?? $warranty->getSerial() : '',
|
||||||
'warranty_class' => $warranty->getWarrantyClass(),
|
'warranty_class' => $warranty->getWarrantyClass(),
|
||||||
'plate_number' => $warranty->getPlateNumber(),
|
'plate_number' => $warranty->getPlateNumber(),
|
||||||
'first_name' => $warranty->getFirstName(),
|
'first_name' => $warranty->getFirstName(),
|
||||||
|
|
@ -1979,7 +1982,7 @@ class APIController extends Controller
|
||||||
'date_purchase' => $warranty->getDatePurchase()->format("d M Y"),
|
'date_purchase' => $warranty->getDatePurchase()->format("d M Y"),
|
||||||
'date_expire' => $expiry_date,
|
'date_expire' => $expiry_date,
|
||||||
'date_claim' => $claim_date,
|
'date_claim' => $claim_date,
|
||||||
'claim_from' => $warranty->getClaimedFrom(),
|
'claim_from' => $warranty->getClaimedFrom() ?? $warranty->getClaimedFrom() : '',
|
||||||
'is_activated' => $warranty->isActivated() ? 1 : 0,
|
'is_activated' => $warranty->isActivated() ? 1 : 0,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue