Merge branch '232-fix-mobile-api-errors' into 'master'

Fix findWarranty bug in API controller #232

Closes #232

See merge request jankstudio/resq!272
This commit is contained in:
Kendrick Chan 2019-07-21 01:52:27 +00:00
commit 43de7d644a

View file

@ -1863,12 +1863,18 @@ class APIController extends Controller
$warranty_results = $em->getRepository(Warranty::class)->findBy(['plate_number' => $plate_number], $warranty_results = $em->getRepository(Warranty::class)->findBy(['plate_number' => $plate_number],
['date_create' => 'desc']); ['date_create' => 'desc']);
$warr = [];
// check if warranty_results is empty // check if warranty_results is empty
if (empty($warranty_results)) if (empty($warranty_results))
{ {
/*
$res->setError(true) $res->setError(true)
->setErrorMessage('No warranty found for plate number'); ->setErrorMessage('No warranty found for plate number');
return $res->getReturnResponse(); return $res->getReturnResponse();
*/
return $warr;
} }
// get first entry // get first entry
@ -1897,7 +1903,6 @@ class APIController extends Controller
$expiry_date = $warranty->getDateExpire()->format("d M Y g:i A"); $expiry_date = $warranty->getDateExpire()->format("d M Y g:i A");
} }
$warr = [];
$warr[] = [ $warr[] = [
'id' => $warranty->getID(), 'id' => $warranty->getID(),
'serial' => $warranty->getSerial(), 'serial' => $warranty->getSerial(),