- 테이블 3개: bad_debts, bad_debt_documents, bad_debt_memos - 모델 3개: BadDebt, BadDebtDocument, BadDebtMemo - BadDebtService: CRUD, 요약 통계, 서류/메모 관리 - API 엔드포인트 11개 (목록, 등록, 상세, 수정, 삭제, 토글, 서류/메모 CRUD) - Swagger 문서 작성 완료
54 lines
1.8 KiB
PHP
54 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\V1\BadDebt;
|
|
|
|
use App\Models\BadDebts\BadDebt;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class UpdateBadDebtRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'client_id' => ['sometimes', 'integer', 'exists:clients,id'],
|
|
'debt_amount' => ['sometimes', 'numeric', 'min:0'],
|
|
'status' => ['sometimes', 'string', Rule::in(array_keys(BadDebt::STATUSES))],
|
|
'overdue_days' => ['sometimes', 'integer', 'min:0'],
|
|
'assigned_user_id' => ['nullable', 'integer', 'exists:users,id'],
|
|
'occurred_at' => ['nullable', 'date'],
|
|
'closed_at' => ['nullable', 'date', 'after_or_equal:occurred_at'],
|
|
'is_active' => ['sometimes', 'boolean'],
|
|
'options' => ['nullable', 'array'],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Get custom messages for validator errors.
|
|
*
|
|
* @return array<string, string>
|
|
*/
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'client_id.exists' => __('validation.exists', ['attribute' => '거래처']),
|
|
'debt_amount.numeric' => __('validation.numeric', ['attribute' => '채권금액']),
|
|
'status.in' => __('validation.in', ['attribute' => '상태']),
|
|
'closed_at.after_or_equal' => __('validation.after_or_equal', ['attribute' => '종료일', 'date' => '발생일']),
|
|
];
|
|
}
|
|
}
|