我正在使用用户表列名(EMAIL,PASSWORD)。如果我正在更改为列名(电子邮件),因为小写字母工作正常。要更改列名称(EMAIL)作为上限不起作用给我任何建议。我能够登录但忘记密码不起作用。请提出任何建议
我在控制器中的功能:
public function postEmail(Request $request)
{
$this->validate($request, array('email' => 'required|email'));
$response = $this->passwords->sendResetLink($request->only('EMAIL'), function ($m) {
$m->subject($this->getEmailSubject());
});
switch ($response) {
case PasswordBroker::RESET_LINK_SENT:
return redirect()->back()->with('status', trans($response));
case PasswordBroker::INVALID_USER:
return redirect()->back()->withErrors(array('email' => trans($response)));
}
}
我在页面中收到此错误:
QueryException in Connection.php line 624:
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'email' cannot be null (SQL: insert into `password_resets` (`email`, `token`,`created_at`)
values (, 5d2b40143e084824402984c81cdfaa64264328bdc9c6d73cf80e1a1aa773d0cc, 2016-07-29 09:52:40))
答案 0 :(得分:1)
表单中的电子邮件字段称为 EMAIL ,因此您的验证将失败,因为它会检查请求中是否存在电子邮件字段。
首先,替换
$this->validate($request, array('email' => 'required|email'));
与
$this->validate($request, array('EMAIL' => 'required|email'));
让我知道它是否已经有效或有其他一些错误,我将通过后续步骤更新答案。请务必发布您收到的错误。
为了存储密码重置令牌,您需要告诉Laravel如何检索用户的电子邮件。您可以通过将以下方法添加到用户模型来执行此操作:
public function getEmailForPasswordReset()
{
return $this->EMAIL;
}