【问题标题】:Laravel 7 undefined method [closed]Laravel 7未定义方法[关闭]
【发布时间】:2021-10-22 08:45:13
【问题描述】:

我正在为登录创建一个自定义控制器,但尝试显示为未定义,我无法解决,请帮助

enter image description here

【问题讨论】:

  • 请分享更多详细信息,例如涉及的代码和确切错误消息
  • 请使用code markup而不是图片分享代码

标签: laravel laravel-7


【解决方案1】:

像这样改变你的变量:

$user = $request->input('username');
$pass = $request->input('password');

如果还是不行,试试这样:

在文件的顶部:

use Illuminate\Support\Facades\Auth;

然后:

$credentials = $request->only('username', 'password');

        if (Auth::attempt($credentials)) {
            // Authentication passed...
            return view('template.index');
        }

这应该可以工作
https://laravel.com/docs/7.x/authentication

【讨论】:

    【解决方案2】:

    要使用 Auth Facade,您必须包含 auth Facades。

    use Illuminate\Support\Facades\Auth;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-23
      • 2012-03-16
      • 1970-01-01
      相关资源
      最近更新 更多