diff --git a/app/Models/ClientPolicyModel.php b/app/Models/ClientPolicyModel.php index 22b8921..0469760 100755 --- a/app/Models/ClientPolicyModel.php +++ b/app/Models/ClientPolicyModel.php @@ -438,11 +438,21 @@ public function getCliendDataForExcelFileName($client_policy_id){ public function getPolicyDetailsForRemainder($client_id = null, $branch_id = null, $policy_id = null) { $builder = $this->table('client_policy') + ->join( + '(SELECT * FROM files + WHERE status = "success" + AND enrollment_open_date <= CURDATE() + AND enrollment_close_date >= CURDATE() + ORDER BY id DESC + LIMIT 1) as files', + 'files.policy_id = client_policy.id' + ) ->where('client_policy.is_active', 1) - ->where('client_policy.policy_status', 1) + ->where('client_policy.policy_status', 1); // ->where('client_policy.is_addon', 1) // ->where('client_policy.inception_type', 2) - ->where('client_policy.open_for_enrollment', 1); + // ->where('client_policy.open_for_enrollment', 1); + if ($client_id && $branch_id) { $builder->where('client_policy.client_id', $client_id) @@ -455,7 +465,11 @@ public function getPolicyDetailsForRemainder($client_id = null, $branch_id = nul $builder->where('client_policy.id', $policy_id); } - return $builder->get()->getResultArray(); + $data = $builder->get()->getResultArray(); + + // print_r($this->db->getLastQuery()->getQuery()); die; + + return $data; } //for this using in CRONE JOB