fix: [card] 카드 상세 수정/저장 누락 필드 9개 보강

- 마이그레이션: card_type, alias, cvc_encrypted, payment_day, total_limit, used_amount, remaining_limit, is_manual, memo 컬럼 추가
- Card 모델: $fillable, $casts, $hidden 확장 + CVC 암호화/복호화 메서드 추가
- CardService: store(), update() 메서드에 9개 필드 처리 로직 추가
- StoreCardRequest, UpdateCardRequest: 9개 필드 검증 규칙 추가
This commit is contained in:
김보곤
2026-02-21 00:11:03 +09:00
parent 961ab47bac
commit 83ddfabd7c
5 changed files with 154 additions and 0 deletions

View File

@@ -22,8 +22,17 @@
* @property string $expiry_date
* @property string|null $card_password_encrypted
* @property string $card_name
* @property string|null $card_type
* @property string|null $alias
* @property string|null $cvc_encrypted
* @property int|null $payment_day
* @property float|null $total_limit
* @property float|null $used_amount
* @property float|null $remaining_limit
* @property string $status
* @property bool $is_manual
* @property int|null $assigned_user_id
* @property string|null $memo
* @property int|null $created_by
* @property int|null $updated_by
* @property int|null $deleted_by
@@ -37,13 +46,22 @@ class Card extends Model
protected $fillable = [
'tenant_id',
'card_company',
'card_type',
'card_number_encrypted',
'card_number_last4',
'expiry_date',
'card_password_encrypted',
'card_name',
'alias',
'cvc_encrypted',
'payment_day',
'total_limit',
'used_amount',
'remaining_limit',
'status',
'is_manual',
'assigned_user_id',
'memo',
'created_by',
'updated_by',
'deleted_by',
@@ -52,12 +70,25 @@ class Card extends Model
protected $hidden = [
'card_number_encrypted',
'card_password_encrypted',
'cvc_encrypted',
];
protected $attributes = [
'status' => 'active',
'is_manual' => false,
];
protected function casts(): array
{
return [
'payment_day' => 'integer',
'total_limit' => 'decimal:2',
'used_amount' => 'decimal:2',
'remaining_limit' => 'decimal:2',
'is_manual' => 'boolean',
];
}
// =========================================================================
// 관계 정의
// =========================================================================
@@ -127,6 +158,26 @@ public function getDecryptedCardPassword(): ?string
: null;
}
/**
* CVC/CVV 암호화 설정
*/
public function setCvc(?string $cvc): void
{
$this->cvc_encrypted = $cvc
? Crypt::encryptString($cvc)
: null;
}
/**
* CVC/CVV 복호화 조회
*/
public function getDecryptedCvc(): ?string
{
return $this->cvc_encrypted
? Crypt::decryptString($this->cvc_encrypted)
: null;
}
// =========================================================================
// 헬퍼 메서드
// =========================================================================