2017-04-12 76 views
0

我已經創建了一個登錄和註冊表單。但我忘了添加一列。所以,我想添加一個名爲「contactNumber」的新列。爲了添加列,我編寫了一個名爲php artisan migrate的命令:在cmd.exe中刷新,並在migration文件夾的create_users_table中寫入代碼。但是,新列的值不會傳遞到mysql數據庫。我究竟做錯了什麼?添加新列後數據庫出錯

enter image description here

enter image description here

回答

1

您需要將新列添加到模型,所以在您的用戶類,你需要這樣做:

protected $fillable = [ 
    'name', 'email', 'password', 'contactNumber' 
]; 

希望這有助於

1

您正嘗試在數據庫中插入新記錄,但contactNumber列沒有默認值。在遷移文件中,您可以爲該列添加空值,例如。

$table->string('contactNumber')->nullable(); 

或直接在GUI中的數據庫中。