我正在 Laravel 中制作注册表,首先我创建迁移
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('first_name');
$table->string('last_name');
$table->string('email')->unique();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('users');
}
}
我想首先注册没有名字和姓氏的姓名、电子邮件和密码,但是当我单击注册时,它给我错误,名字和姓氏没有默认值。那么如何使默认值为空,因为我想更新它稍后列。
$table->string('first_name')->default('DEFAULT');
编辑:如果默认值应该为空,请将其改为可为空。
$table->string('first_name')->nullable();
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)