[WIP] Claim

This commit is contained in:
R
2022-12-08 12:26:29 +07:00
parent 7d8a60f207
commit 32efc28043
7 changed files with 217 additions and 29 deletions

View File

@@ -132,6 +132,21 @@ class Benefit extends Model
"Show Benefit Value" => 'show_benefit_value',
];
public static $max_frequency_periods = [
0 => 'Policy Period',
1 => 'Daily Visit',
2 => 'Weekly',
3 => 'Monthly',
4 => 'Yearly',
5 => 'Disability',
6 => 'Visit',
];
protected $appends = [
'max_frequency_period_name',
'max_frequency'
];
public function setAreaLimitAttribute($value)
{
$this->attributes['area_limit'] = empty($value) ? null : $value;
@@ -168,4 +183,42 @@ class Benefit extends Model
{
return $this->belongsTo(Plan::class, 'plan_code', 'code');
}
public function getMaxFrequencyPeriodNameAttribute()
{
return self::$max_frequency_periods[$this->max_frequency_period] ?? null;
}
public function getMaxFrequencyAttribute()
{
switch ($this->max_frequency_period) {
// case(0) :
// // TODO Fix This
// return null;
// break;
case(1) :
return empty($this->daily_frequency) ? 1 : $this->daily_frequency;
break;
case(2) :
return empty($this->weekly_frequency) ? 1 : $this->weekly_frequency;
break;
case(3) :
return empty($this->monthly_frequency) ? 1 : $this->monthly_frequency;
break;
case(4) :
return empty($this->yearly_frequency) ? 1 : $this->yearly_frequency;
break;
case(5) :
// TODO Fix This
return empty($this->max_period_for_disability) ? 1 : $this->max_period_for_disability;
break;
case(6) :
// TODO Fix This
return 1;
break;
default :
return null;
break;
}
}
}