Skip to content
Advertisement

Should I add ‘ before integers when making an ENUM field

I want to create a Migration and this Migration has a field named is_active which takes one of 1 or 0 values.

So I tried:

$table->enum('is_active', ['0', '1']);

But I wonder, if this alright or I should write it this way:

$table->enum('is_active', [0, 1]);

So which one is true ?

Advertisement

Answer

You can read in the PHP Docs that string '0',int 0,float 0.0 are considered as false and int 1,string '1',float 1.0 are considered as true

Although in your case you can use $table->boolean('is_active'); instead of enum

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement