ProductRequest:
public function rules()
{
return [
//
'name' => 'required|max:255',
'category_id' => 'required|integer',
'price' => 'required|min:500',
'quantity' => 'required|integer|min:1',
'details' => 'required',
'description' => 'required',
'additional' => 'required',
];
}
但问题是只有在我创建新产品时才有效,当我更新它并删除所有字段时,它不会触发。如何在更新产品时验证这些字段?
答案 0 :(得分:0)
适用于任何请求,您只需在ProductRequest
和update()
方法中使用store()
:
public function update(ProductRequest $request)