2017-06-19 47 views
0

我正在使用laravel身份驗證。我改變了電子郵件欄目。而我得到這個錯誤:我已將「電子郵件」列更改爲「userEmail」。現在密碼重置在不工作 - laravel

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'email' in 'where clause' (SQL: delete from password_resets where email is null)

我已經改變了所有電子郵件字段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'); 
    } 
} 

回答

0

,在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; 
} 
+0

這樣做後我沒有收到任何錯誤。它說我們已經通過電子郵件發送了您的密碼重置鏈接!但我沒有收到任何電子郵件。我曾嘗試通過其他用途從laravel發送電子郵件。有用。但沒有密碼重置。我正在使用mailtrap.io –

相關問題