diff --git a/src/Command/UpdateCustomerVehicleWarrantyCommand.php b/src/Command/UpdateCustomerVehicleWarrantyCommand.php index c771044f..89b6e5e0 100644 --- a/src/Command/UpdateCustomerVehicleWarrantyCommand.php +++ b/src/Command/UpdateCustomerVehicleWarrantyCommand.php @@ -92,7 +92,7 @@ class UpdateCustomerVehicleWarrantyCommand extends Command } */ $this->wh->updateCustomerVehicle($serial, $batteries, $plate_number, $expiry_date); - $this->em->clear(); + $this->em->detach($row[0]); } } } diff --git a/src/Service/WarrantyHandler.php b/src/Service/WarrantyHandler.php index c63f0302..bfc30021 100644 --- a/src/Service/WarrantyHandler.php +++ b/src/Service/WarrantyHandler.php @@ -93,9 +93,12 @@ class WarrantyHandler { // find customer vehicle using plate number error_log('Finding customer vehicle with plate number ' . $plate_number); - $cust_vehicles = $this->em->getRepository(CustomerVehicle::class)->findBy(['plate_number' => $plate_number]); + $cv_q = $this->em->createQuery('select count(cv) from App\Entity\CustomerVehicle cv where cv.plate_number = :plate_number') + ->setParameter('plate_number', $plate_number); + $cv_result = $cv_q->getSingleScalarResult(); + $battery_id = null; - if (!empty($cust_vehicles)) + if ($cv_result != 0) { if (!empty($batteries)) { @@ -115,8 +118,8 @@ class WarrantyHandler 'serial' => $serial, 'expiry_date' => $date_expire, 'plate_number' => $plate_number]); - $q->execute(); - } + $q->execute(); + } } public function updateWarranty(Warranty $warr, $first_name, $last_name, $mobile_number, $batt_list, DateTime $date_purchase)