[WIP] Update

This commit is contained in:
R
2023-03-03 08:44:08 +07:00
parent 9e322c4ee5
commit 91ba718a50
17 changed files with 197 additions and 78 deletions

View File

@@ -151,13 +151,20 @@ class Member extends Model
}
public function currentPolicy()
{
return $this->hasOneThrough(CorporatePolicy::class, MemberPolicy::class, 'member_id', 'code', 'member_id', 'policy_id')
->where('status', 'active')
->orderBy('end', 'DESC');
// return $this->hasOne(MemberPolicy::class, 'member_id', 'member_id')->where('status', 'active')->latestOfMany();
}
public function currentActivePolicy()
{
return $this->hasOneThrough(CorporatePolicy::class, MemberPolicy::class, 'member_id', 'code', 'member_id', 'policy_id')
->where('corporate_policies.start', '<', now())
->where('corporate_policies.end', '>', now())
->where('member_policies.start', '<', now())
->where('member_policies.end', '>', now());
// return $this->hasOne(MemberPolicy::class, 'member_id', 'member_id')->where('status', 'active')->latestOfMany();
}
public function getAgeAttribute()