![](/img/trans.png)
[英]SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'office' cannot be null
[英]SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'status' cannot be null
我試圖為狀態設置布爾值,但我發現“狀態”列不能為空。 我該怎么辦? 下面是我為創建用戶表設置的代碼。
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->string('password');
$table->string('role')->nullable();
$table->boolean('status');
$table->string('address')->nullable();
$table->string('city')->nullable();
$table->string('postal_code')->nullable();
$table->string('phone')->nullable();
$table->rememberToken();
$table->timestamps();
});
}
為您的status
列設置默認值
$table->boolean('status')->default(0);
$table->boolean('status')->nullable($value = true);
允許(默認情況下)將 NULL 值插入到列中
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.