如何在更新请求中验证规则? laravel 5

时间:2017-03-16 08:02:14

标签: php laravel validation request

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',
        ];
    }

但问题是只有在我创建新产品时才有效,当我更新它并删除所有字段时,它不会触发。如何在更新产品时验证这些字段?

1 个答案:

答案 0 :(得分:0)

适用于任何请求,您只需在ProductRequestupdate()方法中使用store()

public function update(ProductRequest $request)