[WIP] Store Limit
This commit is contained in:
@@ -57,7 +57,20 @@ class Member extends Model
|
||||
"end_no_claim",
|
||||
];
|
||||
|
||||
protected $appends = ['full_name'];
|
||||
protected $appends = [
|
||||
'full_name',
|
||||
'age',
|
||||
'gender_code'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'deleted_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'deleted_by',
|
||||
];
|
||||
|
||||
public function claims()
|
||||
{
|
||||
@@ -105,12 +118,12 @@ class Member extends Model
|
||||
|
||||
public function plans()
|
||||
{
|
||||
return $this->hasManyThrough(Plan::class, MemberPlan::class, 'member_id', 'code', 'id', 'plan_id');
|
||||
return $this->hasManyThrough(Plan::class, MemberPlan::class, 'member_id', 'id', 'id', 'plan_id');
|
||||
}
|
||||
|
||||
public function currentPlan()
|
||||
{
|
||||
return $this->hasOneThrough(Plan::class, MemberPlan::class, 'member_id', 'code', 'id', 'plan_id')->latest();
|
||||
return $this->hasOneThrough(Plan::class, MemberPlan::class, 'member_id', 'id', 'id', 'plan_id')->latest();
|
||||
}
|
||||
|
||||
public function policies()
|
||||
@@ -120,7 +133,21 @@ class Member extends Model
|
||||
|
||||
public function currentPolicy()
|
||||
{
|
||||
return $this->hasOne(MemberPolicy::class, 'member_id', 'member_id')->where('status', 'active')->latestOfMany();
|
||||
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()
|
||||
{
|
||||
if ($this->birth_date) {
|
||||
return Carbon::parse($this->birth_date)->diffInYears(now());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFullNameAttribute()
|
||||
@@ -137,6 +164,11 @@ class Member extends Model
|
||||
return implode(' ', $arr);
|
||||
}
|
||||
|
||||
public function getGenderCodeAttribute()
|
||||
{
|
||||
return $this->gender ? ($this->gender == 'female' ? 'F' : 'M') : $this->gender;
|
||||
}
|
||||
|
||||
public function scopeFilter($query, array $filters)
|
||||
{
|
||||
$query->when($filters['search'] ?? false, function ($query, $search) {
|
||||
|
||||
Reference in New Issue
Block a user