9 months ago

Request to clarify Eloquent and $dates[] behaviour

Posted 9 months ago by DevMaster

Hello everybody,

Hope you are well.

This confuses me and I wonder if anybody could shed any light:

The Laravel docs state "When a column is considered a date, you may set its value to a UNIX timestamp, date string (Y-m-d), date-time string, or a DateTime / Carbon instance. The date's value will be correctly converted and stored in your database"

but does this behaviour only apply if you add the column to the model's $dates[]? Or does it apply regardless? I have been able to assign Carbon instances to timestamp columns and this has saved correctly to the DB, but the columns were NOT in $dates[]...

Kind regards, Dev

Please sign in or create an account to participate in this conversation.