- BillController: 어음 CRUD + 상태변경 + 요약 API - BillService: 비즈니스 로직 (멀티테넌트 지원) - Bill, BillInstallment 모델: 날짜 포맷(Y-m-d) toArray 오버라이드 - FormRequest: Store/Update/UpdateStatus 유효성 검사 - Swagger 문서: BillApi.php - 마이그레이션: bills, bill_installments 테이블 - DummyBillSeeder: 테스트 데이터 30건 + 차수 12건 - API Routes: /api/v1/bills 엔드포인트 7개
64 lines
2.8 KiB
PHP
64 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\V1\Bill;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class UpdateBillRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'bill_number' => ['nullable', 'string', 'max:50'],
|
|
'bill_type' => ['nullable', 'string', 'in:received,issued'],
|
|
'client_id' => ['nullable', 'integer', 'exists:clients,id'],
|
|
'client_name' => ['nullable', 'string', 'max:100'],
|
|
'amount' => ['nullable', 'numeric', 'min:0'],
|
|
'issue_date' => ['nullable', 'date'],
|
|
'maturity_date' => ['nullable', 'date', 'after_or_equal:issue_date'],
|
|
'status' => ['nullable', 'string', 'in:stored,maturityAlert,maturityResult,paymentComplete,dishonored,collectionRequest,collectionComplete,suing'],
|
|
'reason' => ['nullable', 'string', 'max:255'],
|
|
'installment_count' => ['nullable', 'integer', 'min:0'],
|
|
'note' => ['nullable', 'string', 'max:1000'],
|
|
'is_electronic' => ['nullable', 'boolean'],
|
|
'bank_account_id' => ['nullable', 'integer', 'exists:bank_accounts,id'],
|
|
'installments' => ['nullable', 'array'],
|
|
'installments.*.date' => ['required_with:installments', 'date'],
|
|
'installments.*.amount' => ['required_with:installments', 'numeric', 'min:0'],
|
|
'installments.*.note' => ['nullable', 'string', 'max:255'],
|
|
];
|
|
}
|
|
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'bill_type.in' => __('validation.in', ['attribute' => __('validation.attributes.bill_type')]),
|
|
'amount.min' => __('validation.min.numeric', ['attribute' => __('validation.attributes.amount'), 'min' => 0]),
|
|
'maturity_date.after_or_equal' => __('validation.after_or_equal', ['attribute' => __('validation.attributes.maturity_date'), 'date' => __('validation.attributes.issue_date')]),
|
|
];
|
|
}
|
|
|
|
public function attributes(): array
|
|
{
|
|
return [
|
|
'bill_number' => __('validation.attributes.bill_number'),
|
|
'bill_type' => __('validation.attributes.bill_type'),
|
|
'client_id' => __('validation.attributes.client_id'),
|
|
'client_name' => __('validation.attributes.client_name'),
|
|
'amount' => __('validation.attributes.amount'),
|
|
'issue_date' => __('validation.attributes.issue_date'),
|
|
'maturity_date' => __('validation.attributes.maturity_date'),
|
|
'status' => __('validation.attributes.status'),
|
|
'reason' => __('validation.attributes.reason'),
|
|
'note' => __('validation.attributes.note'),
|
|
'is_electronic' => __('validation.attributes.is_electronic'),
|
|
'bank_account_id' => __('validation.attributes.bank_account_id'),
|
|
];
|
|
}
|
|
}
|