Probably because the model is serialized to be placed on the queue. If the model is likely to still be in the same state, could you re-fetch it?
Apr 8, 2018
3
Level 1
Why don't Model date attributes properly cast when used in a queued job?
I have an Eloquent model, booking. Within that model I define the fields to be automatically cast as Carbon instances:
protected $dates = [
'start_date', 'end_date'
];
But when I try to access those properties in a queued email job to send a notification about a new booking, they are returned as ordinary strings, not Carbon objects (this is in 5.6).
Is there a reason for this? Am I doing something incorrectly?
Please or to participate in this conversation.