我已将“电子邮件”列更改为“userEmail”。现在密码重置在不工作 - laravel
问题描述:
我正在使用laravel身份验证。我改变了电子邮件栏目。而我得到这个错误:我已将“电子邮件”列更改为“userEmail”。现在密码重置在不工作 - laravel
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'email' in 'where clause' (SQL: delete from
password_resets
where
我已经改变了所有电子邮件字段USEREMAIL在ResetsPasswords和SendsPasswordResetEmails文件和意见。我是laravel新手,所以我不了解它是如何工作的。
这里是基于this我password_resets表
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePasswordResetsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('password_resets', function (Blueprint $table) {
$table->string('userEmail', 50)->index();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('password_resets');
}
}
答
,在Laravel默认User
模型使用特征CanResetPassword
,如果你通过它,你会发现这个特别的方法。
/**
* Get the e-mail address where password reset links are sent.
*
* @return string
*/
public function getEmailForPasswordReset()
{
return $this->email;
}
您可以在模型中重写此方法以返回您的案例中正确的电子邮件字段。所以,在App\User
,你应该有以下方法。
public function getEmailForPasswordReset()
{
return $this->userEmail;
}
这样做后我没有收到任何错误。它说我们已经通过电子邮件发送了您的密码重置链接!但我没有收到任何电子邮件。我曾尝试通过其他用途从laravel发送电子邮件。有用。但没有密码重置。我正在使用mailtrap.io –