'integer', 'credit_limit' => 'decimal:2', 'current_usage' => 'decimal:2', ]; protected $attributes = [ 'status' => 'active', 'payment_day' => 15, 'credit_limit' => 0, 'current_usage' => 0, ]; // ========================================================================= // Scopes // ========================================================================= public function scopeActive($query) { return $query->where('status', 'active'); } public function scopeByType($query, string $cardType) { return $query->where('card_type', $cardType); } // ========================================================================= // 헬퍼 메서드 // ========================================================================= public function isActive(): bool { return $this->status === 'active'; } public function toggleStatus(): void { $this->status = $this->status === 'active' ? 'inactive' : 'active'; } /** * 마스킹된 카드번호 */ public function getMaskedCardNumber(): string { $number = preg_replace('/[^0-9]/', '', $this->card_number); if (strlen($number) <= 4) { return $this->card_number; } return '****-****-****-'.substr($number, -4); } }