1
votes

I tried to set boolean for status but i found the column 'status' cannot be null. What should I do? Below is the code I set for create user table.

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();
    });
}
3

3 Answers

1
votes
$table->boolean('status')->nullable($value = true); 

Allows (by default) NULL values to be inserted into the column

1
votes

Set a default value for your status column

$table->boolean('status')->default(0);
0
votes
  • Check If you are inserting Data status has empty value for time of insertion. if you have send status value, please send me code of insertion...