- purchases 테이블에 approval_id 컬럼 추가 (마이그레이션) - Purchase 모델에 approval 관계 정의 - PurchaseService에서 approval 데이터 eager loading 구현 - FormRequest에 approval_id 유효성 검증 추가 - Swagger 문서에 approval 관련 스키마 추가 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
39 lines
1.3 KiB
PHP
39 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\V1\Purchase;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class UpdatePurchaseRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'purchase_date' => ['sometimes', 'date'],
|
|
'client_id' => ['sometimes', 'integer', 'exists:clients,id'],
|
|
'supply_amount' => ['sometimes', 'numeric', 'min:0'],
|
|
'tax_amount' => ['sometimes', 'numeric', 'min:0'],
|
|
'total_amount' => ['sometimes', 'numeric', 'min:0'],
|
|
'purchase_type' => ['nullable', 'string', 'max:50'],
|
|
'description' => ['nullable', 'string', 'max:1000'],
|
|
'withdrawal_id' => ['nullable', 'integer', 'exists:withdrawals,id'],
|
|
'approval_id' => ['nullable', 'integer', 'exists:approvals,id'],
|
|
'tax_invoice_received' => ['sometimes', 'boolean'],
|
|
];
|
|
}
|
|
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'client_id.exists' => __('validation.exists', ['attribute' => '거래처']),
|
|
'supply_amount.numeric' => __('validation.numeric', ['attribute' => '공급가액']),
|
|
'withdrawal_id.exists' => __('validation.exists', ['attribute' => '출금']),
|
|
];
|
|
}
|
|
}
|