select($columns) ->where('is_active',1) ->findAll(); // if($role_id == 2 || $role_id == 3){ // $clients = $this->select($columns) // ->join('client_rm', 'client_rm.client_id = clients.id') // ->where('client_rm.user_id', $user_id) // ->where('clients.is_active',1) // ->findAll(); // } foreach ($clients as &$client) { $clientPolicyModel = new ClientPolicyModel(); $clientPolicies = $clientPolicyModel ->select([' client_branch.id as branch_id', 'client_branch.branch_name', 'client_branch.branch_code', 'client_branch.client_id', 'client_policy.id as client_policy_id', 'client_policy.policy_terms', 'client_policy.policy_no', 'p.name', 'pt.policy_type', ]) ->join('client_branch', 'client_branch.id = client_policy.client_branch_id') ->join('policies p', 'p.id = client_policy.policy_id') ->join('policy_type pt','client_policy.policy_type_id = pt.id') ->where('client_policy.client_id',$client['id']) ->where('client_policy.is_active', 1) ->where('client_policy.policy_status', 1) ->findAll(); $client['policies'] = $clientPolicies; $clientBranchModel = new ClientBranchModel(); $clientBranchs = $clientBranchModel->select(['client_branch.id','client_branch.branch_name','client_branch.branch_code', 'client_branch.client_id']) ->where('client_branch.client_id',$client['id']) ->findAll(); $client['branchs'] = $clientBranchs; } //print_r(($clients));die(); return $clients; } public function getCreatedByUserName(){ return $this->db->table('clients') ->select('clients.*') ->where('is_active', 1) ->get() ->getResult(); } }