'integer', 'unit_price' => 'integer', 'total_amount' => 'integer', 'billed_at' => 'date', 'created_at' => 'datetime', 'updated_at' => 'datetime', ]; /** * 서비스 유형 라벨 */ public const SERVICE_TYPES = [ 'tax_invoice' => '전자세금계산서', 'bank_account' => '계좌조회', 'card' => '카드내역', 'hometax' => '홈텍스 매입/매출', ]; /** * 과금 유형 라벨 */ public const BILLING_TYPES = [ 'subscription' => '월정액', 'usage' => '건별', ]; /** * 건별 단가 (원) */ public const USAGE_UNIT_PRICES = [ 'tax_invoice' => 100, // 전자세금계산서 건당 100원 ]; /** * 바로빌 회원사 관계 */ public function member(): BelongsTo { return $this->belongsTo(BarobillMember::class, 'member_id'); } /** * 서비스 유형 라벨 */ public function getServiceTypeLabelAttribute(): string { return self::SERVICE_TYPES[$this->service_type] ?? $this->service_type; } /** * 과금 유형 라벨 */ public function getBillingTypeLabelAttribute(): string { return self::BILLING_TYPES[$this->billing_type] ?? $this->billing_type; } /** * 특정 월 조회 */ public function scopeOfMonth($query, string $billingMonth) { return $query->where('billing_month', $billingMonth); } /** * 월정액만 조회 */ public function scopeSubscription($query) { return $query->where('billing_type', 'subscription'); } /** * 건별만 조회 */ public function scopeUsage($query) { return $query->where('billing_type', 'usage'); } /** * 특정 서비스 조회 */ public function scopeOfService($query, string $serviceType) { return $query->where('service_type', $serviceType); } }