<?php

namespace Functional\Programs\Http\Resources;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

/**
 * Un programme, avec son planning de créneaux (chargé via programSlots).
 */
class ProgramResource extends JsonResource
{
    public function toArray(Request $request): array
    {
        return [
            'id' => $this->id,
            'name' => $this->name,
            'description' => $this->description,
            'duration_weeks' => $this->duration_weeks,
            'days_per_week' => $this->days_per_week,
            'slots' => ProgramSlotResource::collection($this->whenLoaded('programSlots')),
        ];
    }
}
