From 4753a877b76edaebb9a0c64f98fafe03e436414e Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 9 Dec 2025 09:41:49 +0530 Subject: [PATCH] FIX_DELETE --- app/Controllers/EmployeeRestController.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php index 12d9020..b614320 100755 --- a/app/Controllers/EmployeeRestController.php +++ b/app/Controllers/EmployeeRestController.php @@ -537,10 +537,18 @@ class EmployeeRestController extends AdminController ->update(); } - $this->employeePolicyModel->where('employee_id',$this->request->getGet('id') ) - ->where('is_active', 1 ) - ->set(array('is_active'=> 0 )) - ->update(); + $query = $this->employeePolicyModel + ->where('employee_id', $this->request->getGet('id')) + ->where('is_active', 1); + + // 👉 Add condition only if client_policy_id exists + $clientPolicyId = $this->request->getGet('client_policy_id') ?? null; + if (!empty($clientPolicyId)) { + $query->where('client_policy_id', $clientPolicyId); + } + + $query->set(['is_active' => 0])->update(); + return $this->respond(['status' => 'success','code' => 200,'data' =>[] ], 200);