$sections */ public function __construct( #[WithCast(CollectionCast::class, target: SectionData::class)] #[WithTransformer(CollectionTransformer::class, target: SectionData::class)] public Collection $sections ) { } public function fields(): FieldCollection { return $this->sections->reduce( fn ($carry, $current) => $carry->merge($current->fields->all()), new FieldCollection([]) ); } }