From 6655869c4f6f55d23c13c4f05abf8c0199e1f1af Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Wed, 31 Jul 2019 02:19:46 +0000 Subject: [PATCH] Activate all warranties found for a plate number. #238 --- src/Controller/APIController.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/Controller/APIController.php b/src/Controller/APIController.php index 4510fbf8..3965c4f2 100644 --- a/src/Controller/APIController.php +++ b/src/Controller/APIController.php @@ -1890,17 +1890,12 @@ class APIController extends Controller return $res->getReturnResponse(); } - // get first entry - $warranty = current($warranty_results); - if ($warranty->isActivated()) + // activate all entries + foreach ($warranty_results as $warranty) { - $res->setError(true) - ->setErrorMessage('Warranty already activated'); - return $res->getReturnResponse(); + $warranty->setActivated(); } - $warranty->setActivated(); - $em->flush(); return $res->getReturnResponse();