first version
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Mini;
|
||||
|
||||
use Modules\Common\Http\Requests\BaseFormRequest;
|
||||
|
||||
/**
|
||||
* 小程序下单 验证(金额一律服务端重算,前端不传金额字段)
|
||||
*/
|
||||
class MiniOrderRequest extends BaseFormRequest
|
||||
{
|
||||
protected $stopOnFirstFailure = true;
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'items' => 'required|array|min:1',
|
||||
'items.*.product_id' => 'required|integer|exists:product,id',
|
||||
'items.*.quantity' => 'required|numeric|min:0.01',
|
||||
'remark' => 'nullable|string|max:255',
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'items.required' => '请至少选择一件商品',
|
||||
'items.min' => '请至少选择一件商品',
|
||||
'items.*.product_id.required' => '下单商品不能为空',
|
||||
'items.*.product_id.exists' => '商品不存在',
|
||||
'items.*.quantity.required' => '订货数量不能为空',
|
||||
'items.*.quantity.numeric' => '订货数量必须为数字',
|
||||
'items.*.quantity.min' => '订货数量必须大于 0',
|
||||
'remark.max' => '订单备注最长 255 个字符',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user