mirror of
https://github.com/koel/koel
synced 2024-11-15 00:47:18 +00:00
33 lines
859 B
PHP
33 lines
859 B
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use App\Values\QueueState;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class QueueStateResource extends JsonResource
|
|
{
|
|
public const JSON_STRUCTURE = [
|
|
'songs' => [
|
|
SongResource::JSON_STRUCTURE,
|
|
],
|
|
'current_song',
|
|
'playback_position',
|
|
];
|
|
|
|
public function __construct(private readonly QueueState $state)
|
|
{
|
|
parent::__construct($state);
|
|
}
|
|
|
|
/** @inheritdoc */
|
|
public function toArray($request): array
|
|
{
|
|
return [
|
|
'type' => 'queue-states',
|
|
'songs' => SongResource::collection($this->state->playables),
|
|
'current_song' => $this->state->currentPlayable ? new SongResource($this->state->currentPlayable) : null,
|
|
'playback_position' => $this->state->playbackPosition,
|
|
];
|
|
}
|
|
}
|