'integer', 'additional_unit' => 'integer', 'additional_price' => 'integer', 'is_active' => 'boolean', 'sort_order' => 'integer', ]; // ========================================================================= // 스코프 // ========================================================================= public function scopeActive($query) { return $query->where('is_active', true); } // ========================================================================= // 헬퍼 메서드 // ========================================================================= public static function getByServiceType(string $serviceType): ?self { return static::active()->where('service_type', $serviceType)->first(); } public static function getAllActive() { return static::active()->orderBy('sort_order')->get(); } public function getServiceTypeLabelAttribute(): string { return match ($this->service_type) { self::TYPE_CARD => '카드조회', self::TYPE_TAX_INVOICE => '전자세금계산서', self::TYPE_BANK_ACCOUNT => '계좌조회', default => $this->service_type, }; } public function calculateBilling(int $usageCount): int { if ($usageCount <= $this->free_quota) { return 0; } $excess = $usageCount - $this->free_quota; $units = (int) ceil($excess / max($this->additional_unit, 1)); return $units * $this->additional_price; } }