GWM : claim delete api
This commit is contained in:
parent
0bc046f48a
commit
c751a82c19
@ -150,6 +150,7 @@ $routes->group('api', ['filter' => ["jwtAuth:1,2,3,4,agent","appSignature"] ], f
|
|||||||
$routes->get('claim/ClaimList', 'ClaimController::ClaimList');
|
$routes->get('claim/ClaimList', 'ClaimController::ClaimList');
|
||||||
$routes->get('claim/getClaimById', 'ClaimController::getClaimById');
|
$routes->get('claim/getClaimById', 'ClaimController::getClaimById');
|
||||||
$routes->get('claim/downloadClaimFile', 'ClaimController::downloadClaimFile');
|
$routes->get('claim/downloadClaimFile', 'ClaimController::downloadClaimFile');
|
||||||
|
$routes->get('claim/deleteClaim', 'ClaimController::deleteClaim');
|
||||||
$routes->post('claim/createClaim', 'ClaimController::createClaim');
|
$routes->post('claim/createClaim', 'ClaimController::createClaim');
|
||||||
$routes->post('claim/updateClaim', 'ClaimController::updateClaim');
|
$routes->post('claim/updateClaim', 'ClaimController::updateClaim');
|
||||||
|
|
||||||
|
|||||||
@ -351,6 +351,63 @@ class ClaimController extends ResourceController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Soft delete claim by id (sets is_active = 0).
|
||||||
|
* Also soft deletes related claim files.
|
||||||
|
*/
|
||||||
|
public function deleteClaim()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$claimId = $this->request->getGet('id');
|
||||||
|
|
||||||
|
if (empty($claimId)) {
|
||||||
|
return $this->respond(['status' => 'failed', 'code' => 400, 'data' => 'id is required'], 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
$claim = $this->ClaimModel
|
||||||
|
->where('id', (int) $claimId)
|
||||||
|
->where('is_active', 1)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if (!$claim) {
|
||||||
|
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => 'Claim not found'], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$updatedBy = $this->request->getGet('updated_by');
|
||||||
|
|
||||||
|
$this->db->transStart();
|
||||||
|
|
||||||
|
$this->ClaimModel->update((int) $claimId, [
|
||||||
|
'is_active' => 0,
|
||||||
|
'updated_by' => $updatedBy ?? null,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->ClaimFilesModel
|
||||||
|
->where('claim_id', (int) $claimId)
|
||||||
|
->where('is_active', 1)
|
||||||
|
->set([
|
||||||
|
'is_active' => 0,
|
||||||
|
'updated_by' => $updatedBy ?? null,
|
||||||
|
])
|
||||||
|
->update();
|
||||||
|
|
||||||
|
if ($this->db->transStatus() === false) {
|
||||||
|
$this->db->transRollback();
|
||||||
|
return $this->respond(['status' => 'failed', 'code' => 500, 'data' => 'Failed to delete claim'], 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->db->transComplete();
|
||||||
|
|
||||||
|
return $this->respond([
|
||||||
|
'status' => 'success',
|
||||||
|
'code' => 200,
|
||||||
|
'data' => 'Claim deleted successfully',
|
||||||
|
], 200);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return $this->respond(['status' => 'failed', 'code' => 500, 'data' => $e->getMessage()], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch a single claim by primary id with related lookups and file preview URLs.
|
* Fetch a single claim by primary id with related lookups and file preview URLs.
|
||||||
* Used to populate the edit form when the user clicks the edit button on a row.
|
* Used to populate the edit form when the user clicks the edit button on a row.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user