'service_code', "Plan" => 'plan_code', "Benefit Code" => 'code', "Customer Benefit Code" => 'corporate_benefit_code', "Detail Benefit" => 'description', "ASO/Budget" => 'budget', "Budget Condition" => 'budget_conditions', "Budget Code" => 'budget_code', "Primary benefit" => 'primary_benefit_code', "Benefit Mode" => 'benefit_mode', "Room Class" => 'room_class_coverage', "Max Bed" => 'max_bed_coverage', "Tolerance Paramater" => 'tolerance_parameter', "Max. Room Class" => 'max_room_class', "Limit Value" => 'limit_amount', "Area" => 'area_limit', "Shared Benefit With" => 'shared_benefit', "Shared Benefit Type" => 'shared_benefit_type', "MSC" => 'msc', "Gender" => 'genders', "Min Age" => 'min_age', "Max Age" => 'max_age', "Freq. Period" => 'max_frequency_period', "Daily Frequency" => 'daily_frequency', "Weekly Frequency" => 'weekly_frequency', "Monthly Frequency" => 'monthly_frequency', "Yearly Frequency" => 'yearly_frequency', "Custom Duration" => 'custom_frequency_days', "Custom Duration Value" => 'custom_duration_value', "Cashless, Reimbursement" => 'allowed_transaction_types', "High Plan Factor" => 'high_plan_factor', "Pre Post Treatment" => 'pre_post_treatment', "Pre Treatment" => 'pre_treatment_days', "Post Treatment" => 'post_treatment_days', "Layer Type 1" => 'layer_type_1', "Layer Value 1" => 'layer_value_1', "Layer Type 2" => 'layer_type_2', "Layer Value 2" => 'layer_value_2', "Cashless (%)" => 'cashless_percentage', "Reimburse (%)" => 'reimbursement_percentage', "Digital (%)" => 'digital_percentage', "CoShareM (%)" => 'co_share_m_percentage', "CoShareS (%)" => 'co_share_s_percentage', "CoShareC (%)" => 'co_share_c_percentage', "Cashless Deductible" => 'cashless_deductible', "Reimbursement Deductible" => 'reimbursement_deductible', "Digital Deductible" => 'digital_deductible', "DeductibleM" => 'co_share_m_deductible', "DeductibleS" => 'co_share_s_deductible', "DeductibleC" => 'co_share_c_deductible', "Prorate Type" => 'prorate_type', "Prorate Lookup" => 'prorate_lookup', "Max Days for Disability" => 'max_days_for_disability', "Max Periode of Disability" => 'max_period_for_disability', "Currency" => 'currency', "Show Benefit Item" => 'show_benefit_item', "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; } public function setPrePostTreatmentAttribute($value) { $this->attributes['pre_post_treatment'] = empty($value) ? null : ($value == 'Y'); } public function getPrePostTreatmentAttribute($value) { return empty($value) ? null : ($value ? 'Y' : 'N'); } 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; } } public function benefit() { return $this->belongsTo(Benefit::class); } public function corporate() { return $this->belongsTo(Corporate::class); } public function plan() { return $this->belongsTo(Plan::class); } public function scopeActive($query) { $query->where('active', 1); } public function scopeFilter($query, array $filters) { $query->when($filters['search'] ?? false, function ($query, $search) { return $query ->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 . "%"); }); } }