'decimal:4', 'max_value' => 'decimal:4', 'sort_order' => 'integer', ]; protected $attributes = [ 'result_type' => 'fixed', 'sort_order' => 0, ]; public const RESULT_FIXED = 'fixed'; public const RESULT_FORMULA = 'formula'; // ========================================================================= // Relationships // ========================================================================= public function formula(): BelongsTo { return $this->belongsTo(QuoteFormula::class, 'formula_id'); } // ========================================================================= // Helper Methods // ========================================================================= /** * 값이 범위 내에 있는지 확인 */ public function isInRange($value): bool { $min = $this->min_value; $max = $this->max_value; if (is_null($min) && is_null($max)) { return true; } if (is_null($min)) { return $value <= $max; } if (is_null($max)) { return $value >= $min; } return $value >= $min && $value <= $max; } /** * 범위 표시 문자열 */ public function getRangeLabelAttribute(): string { $min = $this->min_value; $max = $this->max_value; if (is_null($min) && is_null($max)) { return '전체'; } if (is_null($min)) { return "~ {$max}"; } if (is_null($max)) { return "{$min} ~"; } return "{$min} ~ {$max}"; } }