From 7829aa560b57b6411cc96799db9a10b186b840ce Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Mon, 2 Feb 2026 10:38:38 +0530 Subject: [PATCH 1/2] Soft delete : GWM --- app/Config/Routes.php | 1 + app/Controllers/PolicyController.php | 73 ++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 3d63bd2..5c7499a 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -129,6 +129,7 @@ $routes->group('api', ['filter' => 'appSignature'], function ($routes) { $routes->post('policy/calculateCommissionRequest', 'PolicyController::calculateCommissionRequest'); $routes->get("policy/vehicleTypeMaster", "PolicyController::vehicleTypeMaster"); $routes->get("policy/fuelTypeMaster", "PolicyController::fuelTypeMaster"); + $routes->get("policy/softdelete", "PolicyController::softdelete"); //claims diff --git a/app/Controllers/PolicyController.php b/app/Controllers/PolicyController.php index fcaa7e9..f9b3b54 100644 --- a/app/Controllers/PolicyController.php +++ b/app/Controllers/PolicyController.php @@ -1318,6 +1318,79 @@ class PolicyController extends ResourceController } + public function softdelete() + { + try { + $policyId = (int) $this->request->getPost('policy_id'); + + if (!$policyId) { + return $this->respond([ + 'status' => 'failed', + 'code' => 400, + 'data' => 'policy_id is required' + ], 400); + } + + $policy = $this->PolicyModel->find($policyId); + + if (!$policy) { + return $this->respond([ + 'status' => 'failed', + 'code' => 404, + 'data' => 'Data Not Found' + ], 404); + } + + // Start DB transaction + $db = \Config\Database::connect(); + $db->transStart(); + + // Soft delete policy + $this->PolicyModel->update($policyId, ['is_active' => 0]); + + // Soft delete quotation + if (!empty($policy['quotation_id'])) { + $this->QuotationModel->update( + (int) $policy['quotation_id'], + ['is_active' => 0] + ); + } + + // Soft delete enquiry + if (!empty($policy['enquiry_id'])) { + $this->EnquiryModel->update( + (int) $policy['enquiry_id'], + ['is_active' => 0] + ); + } + + $db->transComplete(); + + if ($db->transStatus() === false) { + return $this->respond([ + 'status' => 'failed', + 'code' => 500, + 'data' => 'Failed to delete data' + ], 500); + } + + return $this->respond([ + 'status' => 'success', + 'code' => 200, + 'data' => 'Deleted Successfully!' + ], 200); + + } catch (\Throwable $e) { + return $this->respond([ + 'status' => 'failed', + 'code' => 500, + 'message' => $e->getMessage() + ], 500); + } + } + + + From d50f286e64e952bb8cf08449264ec2a07f50911a Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Mon, 2 Feb 2026 11:15:12 +0530 Subject: [PATCH 2/2] Soft delete : GWM --- app/Controllers/PolicyController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Controllers/PolicyController.php b/app/Controllers/PolicyController.php index f9b3b54..3c94ad4 100644 --- a/app/Controllers/PolicyController.php +++ b/app/Controllers/PolicyController.php @@ -1321,7 +1321,7 @@ class PolicyController extends ResourceController public function softdelete() { try { - $policyId = (int) $this->request->getPost('policy_id'); + $policyId = (int) $this->request->getGet('policy_id'); if (!$policyId) { return $this->respond([