更改 Laravel 8 凭据匹配验证的错误密钥?

Change the error key of Laravel 8 credential matching validation?

我在 LoginController 中更改后:

/**
     * Get the needed authorization credentials from the request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    protected function credentials(\Illuminate\Http\Request $request)
    {
        return [
            'email' => $request->input('login_email'),
            'password' => $request->input('login_password'),
        ];
    }

我能够得到“login_email”作为用户尝试登录而不填写电子邮件输入的关键。

"login_email" => array:1 [▼
    0 => "The login email field is required."
  ]

但是,当凭据不匹配时,错误键是“email”,我也希望它是“login_email”:

"email" => array:1 [▼
    0 => "These credentials do not match our records."
  ]

我需要做什么才能更改匹配的凭据错误密钥?

我在 resources/lang/en/auth.php 文件中看到“这些凭据与我们的记录不匹配”的密钥。 'failed' 有没有办法将“电子邮件”键重命名为“失败”?

这是正常行为,

在第一个上你正在检查 $request 其中 'login_email' 是表单字段,在第二个 $db_result"email" 是 table.[=15= 上的字段]

一种解决方法是将 'login_email' 重命名为 email,

我所要做的就是在 LoginController 中重写这个函数,但一切都如我所愿:

protected function sendFailedLoginResponse(\Illuminate\Http\Request $request)
    {
        throw ValidationException::withMessages([
            'login_email' => [trans('auth.failed')],
        ])->redirectTo('/');
    }