- 마이그레이션: 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개 필드 검증 규칙 추가
63 lines
2.7 KiB
PHP
63 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\V1\Card;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class StoreCardRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'card_company' => ['required', 'string', 'max:50'],
|
|
'card_type' => ['nullable', 'string', 'max:50'],
|
|
'card_number' => ['required', 'string', 'regex:/^\d{13,19}$/'],
|
|
'expiry_date' => ['required', 'string', 'regex:/^(0[1-9]|1[0-2])\/\d{2}$/'],
|
|
'card_password' => ['nullable', 'string', 'size:2', 'regex:/^\d{2}$/'],
|
|
'card_name' => ['required', 'string', 'max:100'],
|
|
'alias' => ['nullable', 'string', 'max:100'],
|
|
'csv' => ['nullable', 'string', 'max:4'],
|
|
'payment_day' => ['nullable', 'integer', 'min:1', 'max:31'],
|
|
'total_limit' => ['nullable', 'numeric', 'min:0'],
|
|
'used_amount' => ['nullable', 'numeric', 'min:0'],
|
|
'remaining_limit' => ['nullable', 'numeric', 'min:0'],
|
|
'status' => ['nullable', 'string', 'in:active,inactive'],
|
|
'is_manual' => ['nullable', 'boolean'],
|
|
'assigned_user_id' => ['nullable', 'integer', 'exists:users,id'],
|
|
'memo' => ['nullable', 'string', 'max:500'],
|
|
];
|
|
}
|
|
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'card_company.required' => __('validation.required', ['attribute' => __('validation.attributes.card_company')]),
|
|
'card_number.required' => __('validation.required', ['attribute' => __('validation.attributes.card_number')]),
|
|
'card_number.regex' => __('validation.card_number_format'),
|
|
'expiry_date.required' => __('validation.required', ['attribute' => __('validation.attributes.expiry_date')]),
|
|
'expiry_date.regex' => __('validation.expiry_date_format'),
|
|
'card_password.size' => __('validation.card_password_format'),
|
|
'card_password.regex' => __('validation.card_password_format'),
|
|
'card_name.required' => __('validation.required', ['attribute' => __('validation.attributes.card_name')]),
|
|
];
|
|
}
|
|
|
|
public function attributes(): array
|
|
{
|
|
return [
|
|
'card_company' => __('validation.attributes.card_company'),
|
|
'card_number' => __('validation.attributes.card_number'),
|
|
'expiry_date' => __('validation.attributes.expiry_date'),
|
|
'card_password' => __('validation.attributes.card_password'),
|
|
'card_name' => __('validation.attributes.card_name'),
|
|
'status' => __('validation.attributes.status'),
|
|
'assigned_user_id' => __('validation.attributes.assigned_user_id'),
|
|
];
|
|
}
|
|
}
|