2
0
Fork 0
mirror of https://github.com/koel/koel synced 2024-12-25 20:13:06 +00:00
koel/app/Http/Resources/GenreResource.php
2024-07-06 17:44:58 +02:00

32 lines
674 B
PHP

<?php
namespace App\Http\Resources;
use App\Values\Genre;
use Illuminate\Http\Resources\Json\JsonResource;
class GenreResource extends JsonResource
{
public const JSON_STRUCTURE = [
'type',
'name',
'song_count',
'length',
];
public function __construct(private readonly Genre $genre)
{
parent::__construct($genre);
}
/** @return array<mixed> */
public function toArray($request): array
{
return [
'type' => 'genres',
'name' => $this->genre->name,
'song_count' => $this->genre->songCount,
'length' => $this->genre->length,
];
}
}