ardent
ardent copied to clipboard
Updating nullable values
I've got some nullable boolean fields, so that the value can be true, false, or not defined. I'm setting/updating them using a select field with values of '', 0 and 1.
When I update an object, I of course have to explicitly set any null properties otherwise they won't be updated. Is there a way to make this work with fill() or auto-hydration?
Thanks!
Fillable will assign anything which is passed. Because models aren't aware of the underlying database you can't set a field to null if it's not defined. Your best bet would be to use a beforeSave
filter to nullify anything which isn't defined.