37 lines
1.1 KiB
PHP
37 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use App\Models\NutritionPlan;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
/** @mixin NutritionPlan */
|
|
class NutritionPlanResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'source' => $this->source,
|
|
'formulaVersion' => $this->formula_version,
|
|
'calories' => $this->calories,
|
|
'proteins' => $this->proteins,
|
|
'carbs' => $this->carbs,
|
|
'fats' => $this->fats,
|
|
'restingMetabolism' => $this->resting_metabolism,
|
|
'maintenanceCalories' => $this->maintenance_calories,
|
|
'calorieAdjustmentPercent' => $this->calorie_adjustment_percent,
|
|
'calculationDetails' => $this->calculation_details,
|
|
'effectiveFrom' => $this->effective_from?->toISOString(),
|
|
'effectiveUntil' => $this->effective_until?->toISOString(),
|
|
'isActive' => $this->is_active,
|
|
];
|
|
}
|
|
}
|