我已经开始与Laravel(yey)再次合作,我遇到了这个问题:
参数2传递给Illuminate \ Validation \ Factory :: make()必须是数组类型,没有给出
public function submit(Request $request){
if ($request->input('choice') == "1"){
$validation = 'required|min:3|exists:accounts,alias';
}
else {
$validation = 'required|email|exists::accounts,email';
}
$this->validate($request, Validator::make(array('field' => $request->input('field')), array('field' => $validation)));
}
答案 0 :(得分:1)
看起来你做得有些不对劲。我建议你再读一遍文档的验证章节。
http://laravel.com/docs/5.1/validation
但是,我认为这可能会解决您的问题:
public function submit(Request $request){
if ($request->input('choice') == "1"){
$validation = 'required|min:3|exists:accounts,alias';
}
else {
$validation = 'required|email|exists::accounts,email';
}
// Make sure the 'field' is set to whatever <input name="field_name"> you got
$this->validate($request, array('field' => $validation));
}