调用未定义的方法Query \ Builder

时间:2016-03-19 21:21:37

标签: php laravel laravel-5.2

我有一个受保护的功能,我想用它来检查我的登录验证。但是我收到了错误

Call to undefined method Illuminate\Database\Query\Builder::loginValidation

我是否必须为我的功能编写模型?

登录验证:

protected function loginValidation($data)
{
    $rules = array(
      'fname' => 'required|max:255',
      'lname'  => 'required|max:255',
      'email'      => 'required|email|max:255|unique:users',
      'password'   => 'required|min:6|confirmed',
);
    return Validator::make($data, $rules);
}

getLoginCredentials

  protected function getLoginCredentials(Request $request)
  {
    $validator = User::loginValidation(Request::all());

    if($validator->passes())
    {
    return[
    'email'    => Request::input('email'),
    'password' => Request::input('password'),
    'type'     => 1  
    ];

    return true;
    }else{
        return redirect()->back()->withErrors();
    }
  }  

1 个答案:

答案 0 :(得分:0)

我猜用户模型无法看到您的功能。执行 composer dump-autoload 以查看更改是否会反映出来。如果没有尝试新名称,看看它是否有效。