40 lines
1.2 KiB
PHP
40 lines
1.2 KiB
PHP
<?php
|
||
|
||
namespace App\Http\Requests\Purchase;
|
||
|
||
use Modules\Common\Http\Requests\BaseFormRequest;
|
||
|
||
/**
|
||
* 采购明细修改 验证(C4;amount 由后端按 weight>0 ? weight×price : quantity×price 重算)
|
||
*/
|
||
class PurchaseItemUpdateRequest extends BaseFormRequest
|
||
{
|
||
protected $stopOnFirstFailure = true;
|
||
|
||
public function rules(): array
|
||
{
|
||
return [
|
||
'product_name' => 'nullable|string|max:100',
|
||
'product_spec' => 'nullable|string|max:100',
|
||
'price' => 'required|numeric|min:0',
|
||
'quantity' => 'required|numeric|min:0',
|
||
'weight' => 'nullable|numeric|min:0',
|
||
'remark' => 'nullable|string|max:255',
|
||
];
|
||
}
|
||
|
||
public function messages(): array
|
||
{
|
||
return [
|
||
'price.required' => '采购单价不能为空',
|
||
'price.numeric' => '采购单价必须为数字',
|
||
'price.min' => '采购单价不能小于 0',
|
||
'quantity.required' => '采购量不能为空',
|
||
'quantity.numeric' => '采购量必须为数字',
|
||
'quantity.min' => '采购量不能小于 0',
|
||
'weight.numeric' => '实际称重必须为数字',
|
||
'weight.min' => '实际称重不能小于 0',
|
||
];
|
||
}
|
||
}
|