47 lines
1.5 KiB
PHP
47 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Recon;
|
|
|
|
use Modules\Common\Http\Requests\BaseFormRequest;
|
|
|
|
/**
|
|
* 财务对账单 创建/编辑 验证
|
|
*/
|
|
class ReconciliationFormRequest extends BaseFormRequest
|
|
{
|
|
protected $stopOnFirstFailure = true;
|
|
|
|
protected function prepareForValidation(): void
|
|
{
|
|
$this->merge([
|
|
'category_id' => (int) ($this->input('category_id') ?? 0),
|
|
'supplier_id' => (int) ($this->input('supplier_id') ?? 0),
|
|
]);
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'title' => 'required|string|max:100',
|
|
'period_start' => 'required|date_format:Y-m-d',
|
|
'period_end' => 'required|date_format:Y-m-d|after_or_equal:period_start',
|
|
'category_id' => 'required|integer|min:0',
|
|
'supplier_id' => 'required|integer|min:0',
|
|
'remark' => 'nullable|string|max:255',
|
|
];
|
|
}
|
|
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'title.required' => '对账标题不能为空',
|
|
'title.max' => '对账标题最长 100 个字符',
|
|
'period_start.required' => '请选择对账周期开始日期',
|
|
'period_start.date_format' => '开始日期格式为 Y-m-d',
|
|
'period_end.required' => '请选择对账周期结束日期',
|
|
'period_end.date_format' => '结束日期格式为 Y-m-d',
|
|
'period_end.after_or_equal' => '结束日期不能早于开始日期',
|
|
];
|
|
}
|
|
}
|