I have a few flag columns in my model, such as disabled_at
, published_at
, etc. These are all timestamp flags, so they either store a NULL value (i.e. not disabled, not published) or a timestamp of when they were disabled or published. I'm dealing with some legacy data migration right now and I don't have the timestamps for the disabling and publishing of certain rows, so what value would be best to store in these columns?
Laravel's soft-delete feature documentation says any non-null value is considered as a set flag, which seems fine, but if I just go ahead and put 1
in the columns I mentioned, it will be a problem when casting the columns as Carbon objects.
If I add a custom attribute, for eg. $model->disabled
, I could make the first one check for a non-null value in $model->disabledAt
and return the appropriate boolean value, but the casting problem persists.
Keeping both disabled
as well as disabledAt
is obviously not something I'm looking to do.
I'm using Laravel and MySQL, but this is something that should apply to any system in theory.