Files
band-management/api/app/Http/Resources/Api/V1/SetlistResource.php

30 lines
934 B
PHP

<?php
declare(strict_types=1);
namespace App\Http\Resources\Api\V1;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
final class SetlistResource extends JsonResource
{
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'name' => $this->name,
'description' => $this->description,
'total_duration_seconds' => $this->total_duration_seconds,
'formatted_duration' => $this->formattedDuration(),
'is_template' => $this->is_template,
'is_archived' => $this->is_archived,
'items' => SetlistItemResource::collection($this->whenLoaded('items')),
'creator' => new UserResource($this->whenLoaded('creator')),
'created_at' => $this->created_at->toIso8601String(),
'updated_at' => $this->updated_at->toIso8601String(),
];
}
}