调用未定义的方法Illuminate \ Auth \ SessionGuard :: guard()

时间:2017-08-08 19:37:14

标签: php laravel

得到了这个错误,但我怀疑这是我尝试拨打customers后卫的方式。如何使用$this->auth而不是我见过的所有Auth::guard示例来调用它?

    if ($this->auth::guard('customers')->attempt(['email' => $email, 'password' => $password], true) === false) {
        return Redirect::back()
            ->with(['message' => 'Your username/password combination was incorrect', 'failed' => true])
            ->withInput();
    }

1 个答案:

答案 0 :(得分:2)

更改

$this->auth::guard('customers')

\Auth::guard('customers')

auth()->guard('customers')