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