17

This is my current code.

public function up()
{
    Schema::table('render', function (Blueprint $table) {
        $table->boolean('displayed')->default(1);
    });
}`

How to change the default value to 0 as below?

public function up()
{
    Schema::table('render', function (Blueprint $table) {
        $table->boolean('displayed')->default(0);
    });
}
Blip
  • 3,061
  • 5
  • 22
  • 50
Tomeikun
  • 309
  • 1
  • 2
  • 5

2 Answers2

37
public function up()
{
    Schema::table('render', function (Blueprint $table) {
        $table->boolean('displayed')->default(0)->change();
    });
}

Added ->change(). Please see Link

boomx09
  • 13
  • 4
Ganesh Ghalame
  • 6,367
  • 3
  • 24
  • 29
1
Schema::create('users', function (Blueprint $table) {
    $table->id();
    $table->string('name');
    $table->boolean('is_active')->unsigned()->nullable();
    $table->timestamps();
});

is_active column is defined as a nullable boolean column using the boolean data type and the unsigned modifier. This will allow you to use the true and false keywords in your database queries instead of 0 and 1.