laravel 5.2方法[validate1]不存在

时间:2017-10-27 17:36:53

标签: php laravel-5.2

我的验证失败了:

$this->validate($request, [
            'name'           => ['required'],
            'email'          => ['required', 'email', 'unique:organisers',$organiser->id,'organisers_id'],
            'organiser_logo' => ['mimes:jpeg,jpg,png', 'max:10000'],
        ]);

但它适用于此:

$this->validate($request, [
            'name'           => ['required'],
            'email'          => ['required', 'email', 'unique:organisers'],
            'organiser_logo' => ['mimes:jpeg,jpg,png', 'max:10000'],
        ]);

1 个答案:

答案 0 :(得分:2)

此:

'unique:organisers',$organiser->id,'organisers_id'

需要:

'unique:organisers,'.$organiser->id.',organisers_id'

或(注意双引号):

"unique:organisers,{$organiser->id},organisers_id"

,表示“新数组元素”,.表示“添加到此字符串”。