mirror of
https://github.com/koel/koel
synced 2024-12-20 17:43:36 +00:00
34 lines
949 B
PHP
34 lines
949 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Http\Resources;
|
||
|
|
||
|
use App\Models\Album;
|
||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||
|
use Illuminate\Support\Arr;
|
||
|
|
||
|
class AlbumResource extends JsonResource
|
||
|
{
|
||
|
public function __construct(private Album $album)
|
||
|
{
|
||
|
parent::__construct($album);
|
||
|
}
|
||
|
|
||
|
/** @return array<mixed> */
|
||
|
public function toArray($request): array
|
||
|
{
|
||
|
return [
|
||
|
'type' => 'albums',
|
||
|
'id' => $this->album->id,
|
||
|
'name' => $this->album->name,
|
||
|
'artist_id' => $this->album->artist_id,
|
||
|
'artist_name' => $this->album->artist->name,
|
||
|
'cover' => $this->album->cover,
|
||
|
'created_at' => $this->album->created_at,
|
||
|
'length' => $this->album->length,
|
||
|
'play_count' => (int) $this->album->play_count,
|
||
|
'song_count' => (int) $this->album->song_count,
|
||
|
'info' => Arr::wrap($this->album->information),
|
||
|
];
|
||
|
}
|
||
|
}
|