You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been writing tests and I came across a weird thing happening. I have a model that has a protected $casts = [ 'registration_date' => 'date:Y-m-d' ] protected $dates = ['registration_date']
And when I load a record from database this works just fine so my "registration_date" is e.g. 2020-03-23, but when using a make method from factory it is like this doesn't apply so I end up with "registration_date" 2020-03-23 00:00:00 which seams really weird to me.
Anyone got any feedback on why is this happening, or am I doing something wrong?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I have been writing tests and I came across a weird thing happening. I have a model that has a
protected $casts = [ 'registration_date' => 'date:Y-m-d' ] protected $dates = ['registration_date']
And when I load a record from database this works just fine so my "registration_date" is e.g. 2020-03-23, but when using a make method from factory it is like this doesn't apply so I end up with "registration_date" 2020-03-23 00:00:00 which seams really weird to me.
Anyone got any feedback on why is this happening, or am I doing something wrong?
Beta Was this translation helpful? Give feedback.
All reactions