1<?php
2
3// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0.
4// See the LICENCE file in the repository root for full licence text.
5
6namespace App\Transformers;
7
8use App\Models\ArtistAlbum;
9
10class ArtistAlbumTransformer extends TransformerAbstract
11{
12 protected array $availableIncludes = [
13 'tracks',
14 ];
15
16 public function transform(ArtistAlbum $album)
17 {
18 return [
19 'id' => $album->id,
20 'artist_id' => $album->artist_id,
21 'title' => $album->title,
22 'title_romanized' => $album->title_romanized,
23 'genre' => $album->genre,
24 'is_new' => $album->isNew(),
25 'cover_url' => $album->cover_url,
26 ];
27 }
28
29 public function includeTracks(ArtistAlbum $album)
30 {
31 return $this->collection($album->tracks, new ArtistTrackTransformer());
32 }
33}