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
+39 -8
View File
@@ -51,6 +51,7 @@ class User extends Authenticatable implements FilamentUser, HasAvatar, HasLocale
'password',
'avatar_url',
'height',
'target_weight',
'bio',
'account_verified_at',
'certification_purchased_at',
@@ -58,15 +59,13 @@ class User extends Authenticatable implements FilamentUser, HasAvatar, HasLocale
'subscription_store',
'subscription_expires_at',
'subscription_is_trial',
'daily_calorie_goal',
'daily_protein_goal',
'daily_carbs_goal',
'daily_fats_goal',
'physical_activity_level',
'weight_goal',
'pace_preference',
'sex',
'date_of_birth',
'onboarding_completed_at',
'nutrition_estimate_accepted_at',
'terms_accepted_at',
'social_notifications_enabled',
'engagement_reminders_enabled',
@@ -97,16 +96,16 @@ class User extends Authenticatable implements FilamentUser, HasAvatar, HasLocale
'account_verified_at' => 'datetime',
'certification_purchased_at' => 'datetime',
'password' => 'hashed',
'daily_calorie_goal' => 'integer',
'daily_protein_goal' => 'float',
'daily_carbs_goal' => 'float',
'daily_fats_goal' => 'float',
'height' => 'integer',
'target_weight' => 'float',
'physical_activity_level' => PhysicalActivityLevel::class,
'weight_goal' => WeightGoal::class,
'pace_preference' => PacePreference::class,
'sex' => UserSex::class,
'role' => UserRole::class,
'date_of_birth' => 'immutable_date',
'onboarding_completed_at' => 'datetime',
'nutrition_estimate_accepted_at' => 'datetime',
'terms_accepted_at' => 'datetime',
'social_notifications_enabled' => 'boolean',
'engagement_reminders_enabled' => 'boolean',
@@ -146,6 +145,38 @@ class User extends Authenticatable implements FilamentUser, HasAvatar, HasLocale
return $this->hasMany(WorkoutSessions::class);
}
public function nutritionPlans(): HasMany
{
return $this->hasMany(NutritionPlan::class);
}
public function activeNutritionPlan(): HasOne
{
return $this->hasOne(NutritionPlan::class)
->where('is_active', true)
->latestOfMany('effective_from');
}
public function weightEntries(): HasMany
{
return $this->hasMany(WeightEntry::class);
}
public function latestWeightEntry(): HasOne
{
return $this->hasOne(WeightEntry::class)->latestOfMany('measured_at');
}
public function weeklyReviews(): HasMany
{
return $this->hasMany(WeeklyReview::class);
}
public function hasCompletedNutritionOnboarding(): bool
{
return $this->onboarding_completed_at !== null;
}
public function stravaConnection(): HasOne
{
return $this->hasOne(StravaConnection::class);