Run into the same problem.
My fix was it to add the `array` cast to the model attribute.
/**
* @return array<string, string>
*/
protected function casts(): array
{
return [
'areas' => 'array',
];
}
---
Some background.
I create multiple instances of the same model.
Put them into a collection and use mass inserting in the end to increate save speed.
MyModel::insert($models->toArray());
One of the attributes is a mandatory `json` field.
The field is set on the model but `toArray()` remove the content.
---
Beside that I tried `asCollection::class` as described in the documentation:
https://laravel.com/docs/11.x/eloquent-mutators#array-object-and-collection-casting
but it did not work.