wertyu
wertyu

Reputation: 131

defalut valued field cannot be null laravel

I have a table that contains boolean fields with default value.

$table->boolean('status')->default(false);

but it gives this error when my input is null : "Column 'status' cannot be null".

I thought that if the input is null, db set status false as default. Should I use nullable? but this time 'status' field will be null not false.

validation:

'form.status' => 'nullable',

Upvotes: 0

Views: 513

Answers (1)

Ossama Abd
Ossama Abd

Reputation: 468

try php artisan migrate:fresh and insert into the form again

if it doesn't work use $table->boolean('status')->default(false)->nullable()

Upvotes: 2

Related Questions