1

I want to set a filed with BIT data type in mySql using Eloquent.

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

But the active filed is 1, I also tried:

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

Simply I want to run something like this:

 INSERT INTO `steps` (`active`) VALUES (b'0')
Positivity
  • 5,406
  • 6
  • 41
  • 61

1 Answers1

2

Talking about active field: If you want to use active and inactive for flagging active and inactive state of any record (i.e. user model) then you may use tinyint data type.

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

Soft Deleting

Also, Laravel provides built-in mechanism for this kind of operation using a deleted_at field in the table which is known as soft delete. Read more on the manual link given here, it's easy to implement and use.

The Alpha
  • 143,660
  • 29
  • 287
  • 307