2022-06-10 10:47:46 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
|
|
|
|
use App\Values\ExcerptSearchResult;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
|
|
|
|
class ExcerptSearchResource extends JsonResource
|
|
|
|
{
|
2024-01-25 16:21:26 +00:00
|
|
|
public const JSON_STRUCTURE = [
|
|
|
|
'songs' => [
|
|
|
|
SongResource::JSON_STRUCTURE,
|
|
|
|
],
|
|
|
|
'artists' => [
|
|
|
|
ArtistResource::JSON_STRUCTURE,
|
|
|
|
],
|
|
|
|
'albums' => [
|
|
|
|
AlbumResource::JSON_STRUCTURE,
|
|
|
|
],
|
|
|
|
];
|
|
|
|
|
2024-04-18 14:36:28 +00:00
|
|
|
public function __construct(private readonly ExcerptSearchResult $result)
|
2022-06-10 10:47:46 +00:00
|
|
|
{
|
|
|
|
parent::__construct($result);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @return array<mixed> */
|
|
|
|
public function toArray($request): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'songs' => SongResource::collection($this->result->songs),
|
|
|
|
'artists' => ArtistResource::collection($this->result->artists),
|
|
|
|
'albums' => AlbumResource::collection($this->result->albums),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|