25 lines
702 B
PHP
25 lines
702 B
PHP
<?php
|
|||
|
|
|
||
|
|
namespace App\Http\Resources;
|
||
|
|
|
||
|
|
use Illuminate\Http\Request;
|
||
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||
|
|
|
||
|
|
class WorkoutExerciseResource extends JsonResource
|
||
|
|
{
|
||
|
|
public function toArray(Request $request): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'id' => $this->id,
|
||
|
|
'workout_id' => $this->workout_id,
|
||
|
|
'position' => $this->position,
|
||
|
|
'sets' => $this->sets,
|
||
|
|
'reps' => $this->reps,
|
||
|
|
'weight' => $this->weight !== null ? (float) $this->weight : null,
|
||
|
|
'rest_seconds' => $this->rest_seconds,
|
||
|
|
'notes' => $this->notes,
|
||
|
|
'exercise' => new ExerciseResource($this->whenLoaded('exercise')),
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|