[ SongResource::JSON_STRUCTURE, ], 'artists' => [ ArtistResource::JSON_STRUCTURE, ], 'albums' => [ AlbumResource::JSON_STRUCTURE, ], ]; public function __construct(private readonly ExcerptSearchResult $result) { parent::__construct($result); } /** @return array */ public function toArray($request): array { return [ 'songs' => SongResource::collection($this->result->songs), 'artists' => ArtistResource::collection($this->result->artists), 'albums' => AlbumResource::collection($this->result->albums), ]; } }