验证器必须是laravel5.3中的类型数组

时间:2017-05-13 09:54:27

标签: laravel-5.3

错误: enter image description here

我正在尝试以管理员身份登录,并且我定义了警卫,但验证器中有一个错误,即validator()必须是158行中的类型数组。

BranchController:

    public function authenticateBranchAdmin(Request $request){
        $validator = Validator($request, [
Line 158->          'email' => 'required|email',
            'password' => 'required'
        ]);

        if($validator->passes()){
            if(Auth::guard('branch')->attempt([
                'email' =>  $request->email,
                'password'  =>  $request->password,
            ])){
                return redirect('/branch'.'/'.Auth::guard('branch')->id);
            }else{
                if($this->AdminIsVerified($request->email)){
                    $request->session()->flash('message', 'Invalid email or password!');
                }else{
                    $request->session()->flash('message', 'Please Register this Account!');
                }
                return redirect('/Admin/login');
            }
        }else{
            return redirect('/Admin/login')->withErrors($validator)->withInput();
        }
    }

1 个答案:

答案 0 :(得分:0)

您需要将$request转换为arrayarray需要Validator,因此$request代替$request->all()。< / p>