nhance/app/Models/ClientPolicyModel.php
2024-02-29 12:05:44 +05:30

101 lines
3.4 KiB
PHP

<?php
namespace App\Models;
use CodeIgniter\Model;
class ClientPolicyModel extends Model
{
protected $table = 'client_policy';
protected $primaryKey = 'id';
protected $allowedFields = [
"id",
"client_id",
"policy_id",
"insurer_id",
"insurer_branch_id",
"tpa_id",
"tpa_branch_id",
"policy_start_date",
"policy_end_date",
"insured",
"no_of_employees",
"no_of_lives",
"no_lives_at_inception",
"premium_paid_at_inception",
"earned_premium_date",
"claims_incurred_date",
"incurred_claims_ratio",
"claims_experience_for_last_3_years",
"policy_status",
"earned_premium_amount",
"claims_incurred_amount",
"json",
"created_by",
"updated_by",
"Is_active",
];
public function getClientPolicyById($id){
return $this->db->table('client_policy')
->select('insurers.name as insurer_name, insurers.short_name as insurer_short')
->select('tpa.name as tpa_name, tpa.short_name as tpa_short')
->select('policies.name as policy_name')
->select('insurer_branch.branch_name as insurer_branch_name, insurer_branch.branch_code as insurer_branch_code')
->select('tpa_branch.branch_name as tpa_branch_name, tpa_branch.branch_code as tpa_branch_code')
->join('insurers', 'insurers.id = client_policy.insurer_id')
->join('insurer_branch', 'client_policy.insurer_branch_id = insurer_branch.id')
->join('tpa', 'tpa.id = client_policy.tpa_id')
->join('tpa_branch', 'client_policy.tpa_branch_id = tpa_branch.id')
->join('policies', 'policies.id = client_policy.policy_id')
->where('client_policy.id', $id)
->get()
->getResult();
}
public function getClientPolicyByClientId($client_id){
return $this->db->table('client_policy')
->select('client_policy.*')
->select('insurers.name as insurer_name, insurers.short_name as insurer_short')
->select('tpa.name as tpa_name, tpa.short_name as tpa_short')
->select('policies.name as policy_name')
->select('insurer_branch.branch_name as insurer_branch_name, insurer_branch.branch_code as insurer_branch_code')
->select('tpa_branch.branch_name as tpa_branch_name, tpa_branch.branch_code as tpa_branch_code')
->join('insurers', 'insurers.id = client_policy.insurer_id')
->join('insurer_branch', 'client_policy.insurer_branch_id = insurer_branch.id')
->join('tpa', 'tpa.id = client_policy.tpa_id')
->join('tpa_branch', 'client_policy.tpa_branch_id = tpa_branch.id')
->join('policies', 'policies.id = client_policy.policy_id')
->where('client_policy.client_id', $client_id)
->get()
->getResult();
}
public function getPolicyPremium($policy_id){
return $this->db->table('policies')
->select('policy_type.*')
->join('policy_type', 'policy_type.id = policies.policy_type_id')
->where('policies.id', $policy_id)
->get()
->getResult();
}
public function getPolicyPremiumPolicyTypeId($policy_type_id){
return $this->db->table('policies')
->select('policy_type.*')
->join('policy_type', 'policy_type.id = policies.policy_type_id')
->where('policies.id', $policy_type_id)
->get()
->getResult();
}
}