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);