GWM : vehicle type(product) CRUD

This commit is contained in:
Gowtham M 2026-01-05 10:04:31 +05:30
parent 442a0becf9
commit 0cd0be63c9
3 changed files with 147 additions and 10 deletions

View File

@ -35,7 +35,6 @@ $routes->group('api', ['filter' => 'appSignature'], function ($routes) {
//Master
$routes->get('master/getRoleMaster', 'MasterController::getRoleMaster');
$routes->get('master/getVehicleTypeMaster', 'MasterController::getVehicleTypeMaster');
$routes->get('master/getInsurancePlanTypeMaster', 'MasterController::getInsurancePlanTypeMaster');
$routes->get('master/getClaimMaster', 'MasterController::getClaimMaster');
$routes->get('master/getEndorsementMaster', 'MasterController::getEndorsementMaster');
@ -54,6 +53,10 @@ $routes->group('api', ['filter' => 'appSignature'], function ($routes) {
$routes->post('master/createEndorsement', 'MasterController::createEndorsement');
$routes->post('master/updateEndorsement/(:num)', 'MasterController::updateEndorsement/$1');
$routes->post('master/updateEndorsementStatus/(:num)', 'MasterController::updateEndorsementStatus/$1');
$routes->get('master/getVehicleTypeMaster', 'MasterController::getVehicleTypeMaster');
$routes->post('master/createVehicleType', 'MasterController::createVehicleType');
$routes->post('master/updateVehicleType/(:num)', 'MasterController::updateVehicleType/$1');
$routes->post('master/updateVehicleTypeStatus/(:num)', 'MasterController::updateVehicleTypeStatus/$1');
@ -101,6 +104,7 @@ $routes->group('api', ['filter' => 'appSignature'], function ($routes) {
$routes->get('enquiry/updateEnquiryInProgress', 'EnquiryController::updateEnquiryInProgress');
$routes->get('enquiry/updateEnquiryStatus', 'EnquiryController::updateEnquiryStatus');
$routes->get('enquiry/checkVehicleDuplicate', 'EnquiryController::checkVehicleDuplicate'); // VALIDATION
$routes->post('enquiry/setVehicleTypeToEnquiry', 'EnquiryController::setVehicleTypeToEnquiry');
//Proposal

View File

@ -790,4 +790,35 @@ class EnquiryController extends ResourceController
]);
}
public function setVehicleTypeToEnquiry()
{
try {
$data = $this->request->getPost();
if (!isset($data['id'])) {
return $this->respond(['status' => 'failed', 'code' => 200, 'error' => 'ID Required'], 200);
}
$id = $data['id'];
$enquiry = $this->enquiryModel->find($id);
if (!$enquiry) {
return $this->respond(['status' => 'failed', 'code' => 200, 'error' => 'Data Not Found'], 200);
}
$updateData = [
'vehicle_type_id' => $data['vehicle_type_id'] ?? $enquiry['vehicle_type_id'],
'updated_by' => $data['updated_by'] ?? null,
];
$this->enquiryModel->update($id, $updateData);
return $this->respond(['status' => 'success', 'code' => 200, 'message' => 'Enquiry updated successfully'], 200);
} catch (\Exception $e) {
return $this->respond(['status' => 'failed', 'code' => 500, 'error' => $e->getMessage()], 500);
}
}
}

View File

@ -66,16 +66,7 @@ class MasterController extends ResourceController
return $this->respond(['status' => 200,'message' => 'success','data' => $data]);
}
public function getVehicleTypeMaster()
{
$data = $this->VehicleTypeMasterModel->findAll();
if (!$data) {
return $this->failNotFound('No data found');
}
return $this->respond(['status' => 200,'message' => 'success','data' => $data]);
}
public function getInsurancePlanTypeMaster()
{
@ -132,6 +123,117 @@ class MasterController extends ResourceController
return $this->respond(['status' => 200,'message' => 'success','data' => $data]);
}
//Vehicle type CRUD---------------------------------------------------------------------
public function getVehicleTypeMaster()
{
$data = $this->VehicleTypeMasterModel->findAll();
if (!$data) {
return $this->failNotFound('No data found');
}
return $this->respond(['status' => 200,'message' => 'success','data' => $data]);
}
public function createVehicleType()
{
$input = $this->request->getJSON(true);
if (empty($input['vehicle_type'])) {
return $this->response->setJSON(['status' => 404, 'message' => 'Value is required']);
}
// Duplicate check (case-insensitive)
$exists = $this->VehicleTypeMasterModel
->where('LOWER(vehicle_type)', strtolower($input['vehicle_type']))
->where('is_active', 1)
->first();
if ($exists) {
return $this->response->setJSON([
'status' => 404,
'message' => 'Vehicle Type already exists'
]);
}
$data = [
'vehicle_type' => $input['vehicle_type'],
'is_active' => 1,
'created_by' => $input['created_by'] ?? null,
];
$this->VehicleTypeMasterModel->insert($data);
return $this->response->setJSON([
'status' => 200,
'message' => 'Vehicle Type created successfully'
]);
}
public function updateVehicleType($id)
{
$input = $this->request->getJSON(true);
if (!$this->VehicleTypeMasterModel->find($id)) {
return $this->response->setJSON(['status' => 404, 'message' => 'Record not found']);
}
// Duplicate name check (excluding current record)
$checkDuplicate = $this->VehicleTypeMasterModel
->where('LOWER(vehicle_type)', strtolower($input['vehicle_type']))
->where('id !=', $id)
->where('is_active', 1)
->first();
if ($checkDuplicate) {
return $this->response->setJSON([
'status' => 404,
'message' => 'Vehicle Type already exists'
]);
}
$data = [
'vehicle_type' => $input['vehicle_type'] ,
'updated_by' => $input['updated_by'] ?? null,
];
$this->VehicleTypeMasterModel->update($id, $data);
return $this->response->setJSON([
'status' => 200,
'message' => 'Vehicle Type updated successfully'
]);
}
public function updateVehicleTypeStatus($id)
{
$input = $this->request->getJSON(true);
if (!isset($input['is_active'])) {
return $this->response->setJSON([
'status' => 404,
'message' => 'is_active field is required'
]);
}
$record = $this->VehicleTypeMasterModel->find($id);
if (!$record) {
return $this->response->setJSON(['status' => 404, 'message' => 'Record not found']);
}
$status = ($input['is_active'] == 1) ? 0 : 1;
$this->VehicleTypeMasterModel->update($id, [
'is_active' => $status,
'updated_by' => $input['updated_by'] ?? null,
]);
return $this->response->setJSON([
'status' => 200,
'message' => 'Status updated successfully'
]);
}
//Broker CRUD---------------------------------------------------------------------------
public function getAllBrokers()