Merge branch 'main' of bitbucket.org:jubilian/nhance_partner_be
This commit is contained in:
commit
cc48f12340
@ -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
|
||||
|
||||
@ -1318,6 +1318,79 @@ class PolicyController extends ResourceController
|
||||
}
|
||||
|
||||
|
||||
public function softdelete()
|
||||
{
|
||||
try {
|
||||
$policyId = (int) $this->request->getGet('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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user