Aug 11, 2017
0
Level 1
Mutator causes date attributes to be JSON object instead of a serialized date string
I'd like to use Cake\Chronos\Date for my date attributes. Since attribute casting via $casts will give me Carbon\Carbon and there doesn't seem to be a way to change that, I just wrote a mutator for my date attributes. This works as expected, but there's one problem.
In Illuminate\Database\Eloquent\Concerns\HasAttributes the method addCastAttributesToArray() won't reach serializeDate() for mutated attributes, so my JSON response changes from serialized date strings to JSON objects.
Is there anything I can do to prevent this?
Please or to participate in this conversation.