<?php

namespace Functional\Routines\Http\Resources;

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

/**
 * Une ligne du pivot routine_exercises, avec un sous-objet exercice minimal prêt-à-afficher.
 */
class RoutineExerciseResource extends JsonResource
{
    public function toArray(Request $request): array
    {
        return [
            'exercise_id' => $this->exercise_id,
            'position' => $this->position,
            'sets' => $this->sets,
            'target_reps' => $this->target_reps,
            'rest_seconds' => $this->rest_seconds,
            'tempo' => $this->tempo,
            'target_weight' => $this->target_weight,
            'notes' => $this->notes,
            'exercise' => [
                'id' => $this->exercise->id,
                'name' => $this->exercise->name,
                'image_url' => $this->exercise->image_url,
                'target' => $this->exercise->target,
            ],
        ];
    }
}
