public function toArray()
{
return $this->attributes->mapWithKeys(function ($item, $key) {
if (is_subclass_of($item, BaseType::class)) {
/** @var BaseType $item */
return [$key => $item->toArray()];
}
if (is_object($item) && get_class($item) === Carbon::class) {
/** @var $item Carbon */
return [$key => $item->timestamp];
}
return [$key => $item];
})->toArray();
}