feat: history and calculate needs for user
CI / 🧪 Tests Laravel (push) Failing after 2m18s
CI / 🐳 Build & Push Images (push) Has been skipped

This commit is contained in:
2026-08-14 12:45:37 +02:00
parent ea5a5737ec
commit 69372a49ed
51 changed files with 2226 additions and 305 deletions
@@ -0,0 +1,42 @@
<?php
namespace App\Http\Resources;
use App\Models\WeeklyReview;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
/** @mixin WeeklyReview */
class WeeklyReviewResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'periodStart' => $this->period_start?->toDateString(),
'periodEnd' => $this->period_end?->toDateString(),
'averages' => [
'calories' => $this->average_calories,
'proteins' => $this->average_proteins,
'carbs' => $this->average_carbs,
'fats' => $this->average_fats,
],
'loggedDaysCount' => $this->logged_days_count,
'weightEntriesCount' => $this->weight_entries_count,
'weightTrendKg' => $this->weight_trend_kg,
'targetWeightTrendKg' => $this->target_weight_trend_kg,
'status' => $this->status,
'recommendedCalorieAdjustment' => $this->recommended_calorie_adjustment,
'messageCode' => $this->message_code,
'metrics' => $this->metrics,
'generatedAt' => $this->generated_at?->toISOString(),
'acceptedAt' => $this->accepted_at?->toISOString(),
'acceptedNutritionPlanId' => $this->accepted_nutrition_plan_id,
];
}
}