'integer', 'started_at' => 'date', 'ended_at' => 'date', 'is_active' => 'boolean', 'created_at' => 'datetime', 'updated_at' => 'datetime', 'deleted_at' => 'datetime', ]; /** * 서비스 유형 라벨 */ public const SERVICE_TYPES = [ 'bank_account' => '계좌조회', 'card' => '카드내역', 'hometax' => '홈텍스 매입/매출', ]; /** * 기본 월정액 (원) */ public const DEFAULT_MONTHLY_FEES = [ 'bank_account' => 10000, 'card' => 10000, 'hometax' => 10000, ]; /** * 바로빌 회원사 관계 */ 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 getStatusLabelAttribute(): string { if (!$this->is_active) { return '비활성'; } if ($this->ended_at && $this->ended_at->isPast()) { return '종료'; } return '구독중'; } /** * 상태 색상 클래스 */ public function getStatusColorAttribute(): string { if (!$this->is_active) { return 'bg-gray-100 text-gray-800'; } if ($this->ended_at && $this->ended_at->isPast()) { return 'bg-red-100 text-red-800'; } return 'bg-green-100 text-green-800'; } /** * 활성 구독만 조회 */ public function scopeActive($query) { return $query->where('is_active', true) ->where(function ($q) { $q->whereNull('ended_at') ->orWhere('ended_at', '>=', now()->toDateString()); }); } /** * 특정 서비스 유형 조회 */ public function scopeOfService($query, string $serviceType) { return $query->where('service_type', $serviceType); } }