table member dan table benefit

This commit is contained in:
pajri
2022-12-20 17:48:28 +07:00
parent da14589328
commit 88ad144921
17 changed files with 1365 additions and 499 deletions

View File

@@ -146,7 +146,7 @@ class CorporateBenefit extends Model
'max_frequency'
];
public function setAreaLimitAttribute($value)
{
$this->attributes['area_limit'] = empty($value) ? null : $value;
@@ -170,31 +170,31 @@ class CorporateBenefit extends Model
public function getMaxFrequencyAttribute()
{
switch ($this->max_frequency_period) {
// case(0) :
// // TODO Fix This
// return null;
// break;
case(1) :
// case(0) :
// // TODO Fix This
// return null;
// break;
case (1):
return empty($this->daily_frequency) ? 1 : $this->daily_frequency;
break;
case(2) :
case (2):
return empty($this->weekly_frequency) ? 1 : $this->weekly_frequency;
break;
case(3) :
case (3):
return empty($this->monthly_frequency) ? 1 : $this->monthly_frequency;
break;
case(4) :
case (4):
return empty($this->yearly_frequency) ? 1 : $this->yearly_frequency;
break;
case(5) :
case (5):
// TODO Fix This
return empty($this->max_period_for_disability) ? 1 : $this->max_period_for_disability;
break;
case(6) :
case (6):
// TODO Fix This
return 1;
break;
default :
default:
return null;
break;
}
@@ -214,13 +214,19 @@ class CorporateBenefit extends Model
{
return $this->belongsTo(Plan::class);
}
public function scopeFilter($query, array $filters)
{
$query->when($filters['search'] ?? false, function ($query, $search) {
return $query
->where('code', 'like', "%" . $search . "%")
->orWhere('name', 'like', "%" . $search . "%");
->whereHas('benefit', function ($query) use ($search) {
$query->where('code', 'like', "%" . $search . "%")
->orWhere('service_code', 'like', "%" . $search . "%");
})->orWhereHas('plan', function ($query) use ($search) {
$query->where('code', 'like', "%" . $search . "%");
});
// ->where('code', 'like', "%" . $search . "%")
// ->orWhere('name', 'like', "%" . $search . "%");
});
}
}