mardi 5 mai 2015

Laravel 4 Boolean in model

I have been trying to use a Boolean value in laravel TINYINT(1). However although it works fine for true/1 it cannot understand false/0. So if I change it to false it will still read as true as it seems Eloquent ignores the false value.

I have tried strings, ints and normal Boolean but they all have the same effect.

// I pull in the info kind of like this
$fields = Input::all();
$model->never_expires = $field['never_expires'];
$model->save();

never_expires is fillable within the model and uses a laravel boolean (created from the schema generator) which translates to a TINYINT(1).

I'm sure its something super simple I am missing, but I just can't see it.

Aucun commentaire:

Enregistrer un commentaire