nhance_partner_be/app/Controllers/MasterController.php
2025-11-07 10:50:50 +05:30

154 lines
3.9 KiB
PHP

<?php
namespace App\Controllers;
use CodeIgniter\RESTful\ResourceController;
use App\Models\RoleMasterModel;
use App\Models\VehicleTypeMasterModel;
use App\Models\InsurancePlanTypeMasterModel;
use App\Models\ClaimTypeModel;
use App\Models\EndorsementTypeModel;
use App\Models\InsurersModel;
use App\Models\StaffModel;
use App\Models\PartnerBrokerModel;
class MasterController extends ResourceController
{
protected $format = 'json';
protected $myLogger;
protected $RoleMasterModel;
protected $VehicleTypeMasterModel;
protected $InsurancePlanTypeMasterModel;
protected $ClaimTypeModel;
protected $EndorsementTypeModel;
protected $InsurersModel;
protected $StaffModel;
protected $PartnerBrokerModel;
public function __construct()
{
$this->myLogger = \Config\Services::mylogger();
$this->RoleMasterModel = new RoleMasterModel();
$this->VehicleTypeMasterModel = new VehicleTypeMasterModel();
$this->InsurancePlanTypeMasterModel = new InsurancePlanTypeMasterModel();
$this->ClaimTypeModel = new ClaimTypeModel();
$this->EndorsementTypeModel = new EndorsementTypeModel();
$this->InsurersModel = new InsurersModel();
$this->StaffModel = new StaffModel();
$this->PartnerBrokerModel = new PartnerBrokerModel();
}
public function app_test()
{
return $this->respond(['status' => 200,'message' => 'success','data' => []]);
}
public function getRoleMaster()
{
$data = $this->RoleMasterModel->whereIn('id',[2,3])->findAll();
if (!$data) {
return $this->failNotFound('No data found');
}
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()
{
$data = $this->InsurancePlanTypeMasterModel->findAll();
if (!$data) {
return $this->failNotFound('No data found');
}
return $this->respond(['status' => 200,'message' => 'success','data' => $data]);
}
public function getClaimMaster()
{
$data = $this->ClaimTypeModel->select('id,claim_type')->where('is_active',1)->findAll();
if (!$data) {
return $this->failNotFound('No data found');
}
return $this->respond(['status' => 200,'message' => 'success','data' => $data]);
}
public function getEndorsementMaster()
{
$data = $this->EndorsementTypeModel->select('id,endorsement_type')->where('is_active',1)->findAll();
if (!$data) {
return $this->failNotFound('No data found');
}
return $this->respond(['status' => 200,'message' => 'success','data' => $data]);
}
public function getInsurersMaster()
{
$data = $this->InsurersModel->select('id,name')->where('is_active',1)->where('category','general')->findAll();
if (!$data) {
return $this->failNotFound('No data found');
}
return $this->respond(['status' => 200,'message' => 'success','data' => $data]);
}
public function getStaffMaster()
{
$data = $this->StaffModel->select('id,name')->where('is_active',1)->where('role_id',2)->findAll();
if (!$data) {
return $this->failNotFound('No data found');
}
return $this->respond(['status' => 200,'message' => 'success','data' => $data]);
}
public function getAllBrokers()
{
$data = $this->PartnerBrokerModel->where('is_active', 1)->findAll();
return $this->respond(['status' => 200,'message' => 'success','data' => $data]);
}
}