Add body weight logging with a trend on the dashboard

No way existed to log body weight over time - only the single
self-reported value from the signup profile - and the dashboard showed
session activity but nothing about physical progress, which is usually
the main reason people keep using a fitness app.

Adds a WeightLog model (one entry per user per day, re-logging the same
day updates it rather than duplicating), a quick-add form and trend
summary on the dashboard, and delete support.

Found and fixed a real bug along the way: the first implementation used
WeightLog::updateOrCreate() with a raw ['logged_at' => $date] match
array, which silently failed to find the same-day entry because the
`date` cast stores full datetime strings ('2026-01-01 00:00:00') while
the match array holds a plain 'Y-m-d' string - so re-logging the same
day hit a unique-constraint violation instead of updating. Fixed by
using a whereDate() lookup instead, which is comparison-format-safe.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-10 12:10:08 +03:00
co-authored by Claude Sonnet 5
parent 7769d2038a
commit 1cc21ad0c5
11 changed files with 302 additions and 1 deletions
+13
View File
@@ -231,6 +231,19 @@ return [
'activity_30d_help' => 'Număr de sesiuni pe zi (mai mult este mai bine).',
],
'weight_log' => [
'title' => 'Greutate corporală',
'change_since_first' => 'Schimbare de la prima înregistrare:',
'weight_kg' => 'Greutate (kg)',
'date' => 'Data',
'log' => 'Adaugă',
'none' => 'Nicio înregistrare încă. Adaugă prima pentru a-ți urmări evoluția.',
'saved' => 'Greutate înregistrată',
'deleted' => 'Înregistrare ștearsă',
'delete' => 'Șterge',
'confirm_delete' => 'Ștergi această înregistrare?',
],
'admin' => [
'title' => 'Panou de administrare',
'subtitle' => 'Gestionează conținutul și vezi statisticile generale ale site‑ului.',