因此,我正在laravel 5.3中創建一個項目,並試圖修改我的登錄名時偶然發現了錯誤。Laravel將用戶名覆蓋到另一列不起作用
正如標題所說,我正在嘗試使用不同的列而不是'email'登錄,因爲我想爲每個用戶發送3封電子郵件。所以起初我只想改變用戶名從哪裏來。我已經做了以下。
我編輯了config/auth.php
文件傾聽另一種模式是這樣的:
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Models\Guest::class,
]
]
並以我LoginController.php
文件,我重寫功能的用戶名與此:
public function username()
{
return 'email1';
}
這不給我有任何錯誤,但如果我嘗試使用我的數據庫中的憑據登錄,它將不會重定向。任何人都知道快速回答?謝謝!
編輯:
這裏是我的客人表的模式:
Schema::create('guests', function(Blueprint $table){
$table->increments('id');
$table->string('hash')->nullable();
$table->string('password', 60)->nullable();
$table->rememberToken();
$table->string('ip')->nullable();
$table->integer('reunion_id')->unsigned();
$table->string('last_name');
$table->string('middle_name')->nullable();
$table->string('nickname')->nullable();
$table->string('first_name');
$table->string('initials')->nullable();
$table->string('sex')->nullable();
$table->date('birthdate')->nullable();
$table->string('address')->nullable();
$table->string('postcode')->nullable();
$table->string('city')->nullable();
$table->string('location')->nullable();
$table->string('country')->nullable();
$table->string('mobile1')->nullable();
$table->string('mobile2')->nullable();
$table->string('mobile3')->nullable();
$table->string('phone1')->nullable();
$table->string('phone2')->nullable();
$table->string('phone3')->nullable();
$table->string('email1')->nullable()->unique();
$table->string('email2')->nullable();
$table->string('email3')->nullable();
$table->integer('graduation')->nullable();
$table->string('level')->nullable();
$table->boolean('deceased')->nullable();
$table->text('comment')->nullable();
$table->string('linkedin')->nullable();
$table->string('facebook')->nullable();
$table->string('twitter')->nullable();
$table->string('instagram')->nullable();
$table->boolean('found')->default(false);
$table->boolean('claimed')->default(false);
$table->boolean('confirmed')->default(false);
$table->boolean('ticket')->default(false);
$table->timestamps();
});
我意識到,表名是客人和模型客人,但請相信我,他們連接
當您嘗試登錄時發生了什麼? '客人'模型中有什麼? – GiuServ
@GiuServ請看編輯文件,沒有發生任何事情。它只是刷新頁面出於某種原因,它不會重定向到錯誤或正確.. – Hoffie
好@Hoffie,但是客戶擴展'Authenticatable'類? – GiuServ