diff --git a/app/Http/Controllers/GoalController.php b/app/Http/Controllers/GoalController.php index 89ead43..ad0b02e 100644 --- a/app/Http/Controllers/GoalController.php +++ b/app/Http/Controllers/GoalController.php @@ -50,7 +50,10 @@ class GoalController extends Controller */ public function show(Goal $goal): View { - return view('goals.show')->with('goal', $goal); + return view('goals.show') + ->with('goal', $goal) + ->with('nameOptions', Goal::getNameOptions()) + ->with('frequencyOptions', Goal::$frequencyOptions); } /** diff --git a/app/Models/Goal.php b/app/Models/Goal.php index 1bd39d5..691e6b7 100644 --- a/app/Models/Goal.php +++ b/app/Models/Goal.php @@ -43,7 +43,7 @@ final class Goal extends Model * Supported options for thr frequency attribute. */ public static array $frequencyOptions = [ - ['value' => 'daily', 'label' => 'daily'], + 'daily' => ['value' => 'daily', 'label' => 'daily'], ]; /** diff --git a/app/Support/Nutrients.php b/app/Support/Nutrients.php index fc5fa88..8d4ecda 100644 --- a/app/Support/Nutrients.php +++ b/app/Support/Nutrients.php @@ -10,21 +10,21 @@ class Nutrients public static float $gramsPerOunce = 28.349523125; public static array $all = [ - ['value' => 'calories', 'label' => 'calories', 'unit' => null], - ['value' => 'carbohydrates', 'label' => 'carbohydrates', 'unit' => 'g'], - ['value' => 'cholesterol', 'label' => 'cholesterol', 'unit' => 'mg'], - ['value' => 'fat', 'label' => 'fat', 'unit' => 'g'], - ['value' => 'protein', 'label' => 'protein', 'unit' => 'g'], - ['value' => 'sodium', 'label' => 'sodium', 'unit' => 'mg'], + 'calories' => ['value' => 'calories', 'label' => 'calories', 'unit' => null], + 'carbohydrates' => ['value' => 'carbohydrates', 'label' => 'carbohydrates', 'unit' => 'g'], + 'cholesterol' => ['value' => 'cholesterol', 'label' => 'cholesterol', 'unit' => 'mg'], + 'fat' => ['value' => 'fat', 'label' => 'fat', 'unit' => 'g'], + 'protein' => ['value' => 'protein', 'label' => 'protein', 'unit' => 'g'], + 'sodium' => ['value' => 'sodium', 'label' => 'sodium', 'unit' => 'mg'], ]; public static array $units = [ - ['value' => 'cup', 'label' => 'cup'], - ['value' => 'gram', 'label' => 'grams'], - ['value' => 'oz', 'label' => 'oz'], - ['value' => 'serving', 'label' => 'servings'], - ['value' => 'tbsp', 'label' => 'tbsp.'], - ['value' => 'tsp', 'label' => 'tsp.'], + 'cup' => ['value' => 'cup', 'label' => 'cup'], + 'gram' => ['value' => 'gram', 'label' => 'grams'], + 'oz' => ['value' => 'oz', 'label' => 'oz'], + 'serving' => ['value' => 'serving', 'label' => 'servings'], + 'tbsp' => ['value' => 'tbsp', 'label' => 'tbsp.'], + 'tsp' => ['value' => 'tsp', 'label' => 'tsp.'], ]; /** diff --git a/resources/views/goals/edit.blade.php b/resources/views/goals/edit.blade.php index 82fb2bd..94e374b 100644 --- a/resources/views/goals/edit.blade.php +++ b/resources/views/goals/edit.blade.php @@ -20,7 +20,7 @@ + :value="old('from', $goal->from?->toDateString())" /> @@ -29,7 +29,7 @@ + :value="old('to', $goal->to?->toDateString())" /> diff --git a/resources/views/goals/index.blade.php b/resources/views/goals/index.blade.php index bfef1f9..c84e01d 100644 --- a/resources/views/goals/index.blade.php +++ b/resources/views/goals/index.blade.php @@ -36,11 +36,9 @@
- @forelse($goals['present'] as $goal) -
- {{ $goal->summary }} - TODO: Details for the day! -
+
+ @forelse($goals['present'] as $goal) +
@@ -54,11 +52,12 @@ +
{{ $goal->summary }}
-
- @empty -
No goals set.
- @endforelse + @empty +
No goals set.
+ @endforelse +
diff --git a/resources/views/goals/show.blade.php b/resources/views/goals/show.blade.php index 924e65e..853f079 100644 --- a/resources/views/goals/show.blade.php +++ b/resources/views/goals/show.blade.php @@ -21,7 +21,18 @@
- TODO: GOAL SHOW PAGE +
+
From
+
{{ $goal->from?->toDateString() ?? 'Any' }}
+
To
+
{{ $goal->to?->toDateString() ?? 'Any' }}
+
Frequency
+
{{ \Illuminate\Support\Str::ucfirst($frequencyOptions[$goal->frequency]['label']) }}
+
Trackable
+
{{ \Illuminate\Support\Str::ucfirst($nameOptions[$goal->name]['label']) }}
+
Goal
+
{{ $goal->goal }}{{ $nameOptions[$goal->name]['unit'] }}
+
diff --git a/resources/views/journal-entries/index.blade.php b/resources/views/journal-entries/index.blade.php index d4c419e..3851411 100644 --- a/resources/views/journal-entries/index.blade.php +++ b/resources/views/journal-entries/index.blade.php @@ -37,46 +37,58 @@
-
-

{{ $date->format('D, j M Y') }}

-
{{ $entries->count() }} {{ \Illuminate\Support\Pluralizer::plural('entry', $entries->count()) }}
-
% Daily goal
-
-
+
+
+

{{ $date->format('D, j M Y') }}

+
{{ $entries->count() }} {{ \Illuminate\Support\Pluralizer::plural('entry', $entries->count()) }}
+
+
% Daily goal
+
+
Calories {{ number_format($sums['calories']) }}
-
+
{{ $dailyGoals['calories'] ?? 'N/A' }}
-
+
+
+
Fat {{ number_format($sums['fat']) }}g
-
+
{{ $dailyGoals['fat'] ?? 'N/A' }}
-
+
+
+
Cholesterol {{ number_format($sums['cholesterol']) }}mg
-
+
{{ $dailyGoals['cholesterol'] ?? 'N/A' }}
-
+
+
+
Sodium {{ number_format($sums['sodium']) }}mg
-
+
{{ $dailyGoals['sodium'] ?? 'N/A' }}
-
+
+
+
Carbohydrates {{ number_format($sums['carbohydrates']) }}g
-
+
{{ $dailyGoals['carbohydrates'] ?? 'N/A' }}
+
+
Protein {{ number_format($sums['protein']) }}g