Build & Deploy / build (push) Successful in 19s
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
38 lines
1.2 KiB
PHP
38 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Functional\Routines\Http\Resources;
|
|
|
|
use Functional\Exercises\Models\Exercise;
|
|
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
|
|
* (nom + muscle localisés selon la locale de la requête).
|
|
*/
|
|
class RoutineExerciseResource extends JsonResource
|
|
{
|
|
public function toArray(Request $request): array
|
|
{
|
|
$locale = (string) ($request->query('locale') ?: 'fr');
|
|
$exercise = $this->exercise;
|
|
|
|
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' => $exercise ? [
|
|
'id' => $exercise->id,
|
|
'name' => $exercise->localizedName($locale),
|
|
'image_url' => $exercise->image_url,
|
|
'target' => Exercise::localizeTerm($exercise->target, $locale),
|
|
] : null,
|
|
];
|
|
}
|
|
}
|