Laravel 4 Eloquent Assigns BIT Values

I want to set filed with data type BITin mySql using Eloquent.

$i = new Step;
$i->active = 'b0';
$i->save();

But registered active- 1I also tried:

$i->active = "b'0'";
$i->active = '0';
$i->active = false;
...

I just want to run something like this:

 INSERT INTO `steps` (`active`) VALUES (b'0')
0
source share
1 answer

Speaking of the field active: If you want to use activeboth inactivefor status marking activeand inactiveany record (for example, a user model), you can use a data type tinyint.

Bool, Boolean: These types are synonyms for TINYINT (1). A value of zero is considered false. Nonzero values ​​are considered true.

Soft removal

, Laravel deleted_at , soft delete, , .

+2

Source: https://habr.com/ru/post/1569421/


All Articles