php - Should I add ' before integers when making an ENUM field
Get the solution ↓↓↓I want to create a Migration and this Migration has a field namedis_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 ?
Answer
Solution:
You can read in the PHP Docs thatstring '0',int 0,float 0.0
are considered asfalse
andint 1,string '1',float 1.0
are considered astrue
Although in your case you can use$table->boolean('is_active');
instead ofenum
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: using $this when not in object context
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.