mirror of https://github.com/kcal-app/kcal.git
Style journal view
This commit is contained in:
parent
c1ddb061df
commit
2e3db25388
|
|
@ -67,7 +67,7 @@ return [
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'timezone' => 'UTC',
|
'timezone' => env('APP_TIMEZONE', 'UTC'),
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -14,42 +14,84 @@
|
||||||
@endif
|
@endif
|
||||||
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
|
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
|
||||||
<div class="p-6 bg-white border-b border-gray-200">
|
<div class="p-6 bg-white border-b border-gray-200">
|
||||||
<div class="flex flex-row justify-between items-center mb-4">
|
<div class="flex flex-row">
|
||||||
<div><a class="text-gray-500 hover:text-gray-700 hover:border-gray-300" href="{{ route(Route::current()->getName(), ['date' => $date->copy()->subDay(1)->toDateString()]) }}">previous</a></div>
|
<div class="w-1/12 mr-4">
|
||||||
<div class="font-extrabold text-lg">
|
<a class="text-gray-500 hover:text-gray-700 hover:border-gray-300"
|
||||||
{{ $date->format('D, j M Y') }}
|
href="{{ route(Route::current()->getName(), ['date' => $date->copy()->subDay(1)->toDateString()]) }}">
|
||||||
|
previous</a>
|
||||||
</div>
|
</div>
|
||||||
<div><a class="text-gray-500 hover:text-gray-700 hover:border-gray-300" href="{{ route(Route::current()->getName(), ['date' => $date->copy()->addDay(1)->toDateString()]) }}">next</a></div>
|
<div class="w-3/12 mr-4">
|
||||||
</div>
|
<h3 class="font-semibold text-xl text-gray-800">{{ $date->format('D, j M Y') }}</h3>
|
||||||
<div class="flex flex-col space-y-4">
|
<div class="text-gray-700">{{ $entries->count() }} {{ \Illuminate\Support\Pluralizer::plural('entry', $entries->count()) }}</div>
|
||||||
<div>
|
<div class="grid grid-cols-2 text-sm border-t-8 border-black pt-2">
|
||||||
<h3 class="font-semibold text-lg text-gray-800">Totals</h3>
|
<div class="font-extrabold text-lg border-b-4 border-black">Calories</div>
|
||||||
@foreach($nutrients as $nutrient)
|
<div class="font-extrabold text-right text-lg border-b-4 border-black">{{ round($entries->sum('calories'), 2) }}g</div>
|
||||||
{{ round($entries->sum($nutrient), 2) }}g
|
<div class="font-bold border-b border-gray-300">Fat</div>
|
||||||
{{ $nutrient }}@if(!$loop->last), @endif
|
<div class="text-right border-b border-gray-300">{{ round($entries->sum('fat'), 2) }}g</div>
|
||||||
|
<div class="font-bold border-b border-gray-300">Cholesterol</div>
|
||||||
|
<div class="text-right border-b border-gray-300">{{ round($entries->sum('cholesterol'), 2) }}g</div>
|
||||||
|
<div class="font-bold border-b border-gray-300">Sodium</div>
|
||||||
|
<div class="text-right border-b border-gray-300">{{ round($entries->sum('sodium'), 2) }}g</div>
|
||||||
|
<div class="font-bold border-b border-gray-300">Carbohydrates</div>
|
||||||
|
<div class="text-right border-b border-gray-300">{{ round($entries->sum('carbohydrates'), 2) }}g</div>
|
||||||
|
<div class="font-bold">Protein</div>
|
||||||
|
<div class="text-right">{{ round($entries->sum('protein'), 2) }}g</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-col space-y-4 w-full mr-4">
|
||||||
|
@foreach(['breakfast', 'lunch', 'dinner', 'snacks'] as $meal)
|
||||||
|
<div>
|
||||||
|
<h3 class="font-semibold text-lg text-gray-800">
|
||||||
|
{{ Str::ucfirst($meal) }}
|
||||||
|
<span class="text-sm text-gray-500">
|
||||||
|
@foreach($nutrients as $nutrient)
|
||||||
|
{{ round($entries->where('meal', $meal)->sum($nutrient), 2) }}g
|
||||||
|
{{ $nutrient }}@if(!$loop->last), @endif
|
||||||
|
@endforeach
|
||||||
|
</span>
|
||||||
|
</h3>
|
||||||
|
@forelse($entries->where('meal', $meal) as $entry)
|
||||||
|
<details>
|
||||||
|
<summary>{{ $entry->summary }}</summary>
|
||||||
|
<div class="border-blue-100 border-2 p-2 ml-4">
|
||||||
|
<div>
|
||||||
|
<span class="font-bold">nutrients:</span>
|
||||||
|
@foreach($nutrients as $nutrient)
|
||||||
|
{{ round($entry->{$nutrient}, 2) }}g
|
||||||
|
{{ $nutrient }}@if(!$loop->last), @endif
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
@if($entry->foods()->exists())
|
||||||
|
<div>
|
||||||
|
<span class="font-bold">foods:</span>
|
||||||
|
@foreach($entry->foods as $food)
|
||||||
|
{{ $food->name }}@if(!$loop->last), @endif
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
@if($entry->recipes()->exists())
|
||||||
|
<div>
|
||||||
|
<span class="font-bold">recipes:</span>
|
||||||
|
@foreach($entry->recipes as $recipe)
|
||||||
|
<a class="text-gray-500 hover:text-gray-700 hover:border-gray-300"
|
||||||
|
href="{{ route('recipes.show', $recipe) }}">
|
||||||
|
{{ $recipe->name }}</a>@if(!$loop->last), @endif
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</details>
|
||||||
|
@empty
|
||||||
|
<em>No entries.</em>
|
||||||
|
@endforelse
|
||||||
|
</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
</div>
|
</div>
|
||||||
@foreach(['breakfast', 'lunch', 'dinner', 'snacks'] as $meal)
|
<div class="w-1/12 text-right">
|
||||||
<div>
|
<a class="text-gray-500 hover:text-gray-700 hover:border-gray-300"
|
||||||
<h3 class="font-semibold text-lg text-gray-800">
|
href="{{ route(Route::current()->getName(), ['date' => $date->copy()->addDay(1)->toDateString()]) }}">
|
||||||
{{ Str::ucfirst($meal) }}
|
next</a>
|
||||||
</h3>
|
</div>
|
||||||
<div class="text-xs">
|
|
||||||
@foreach($nutrients as $nutrient)
|
|
||||||
{{ round($entries->where('meal', $meal)->sum($nutrient), 2) }}g
|
|
||||||
{{ $nutrient }}@if(!$loop->last), @endif
|
|
||||||
@endforeach
|
|
||||||
</div>
|
|
||||||
@forelse($entries->where('meal', $meal) as $entry)
|
|
||||||
<details>
|
|
||||||
<summary>{{ $entry->summary }}</summary>
|
|
||||||
{{ $entry->calories }}
|
|
||||||
</details>
|
|
||||||
@empty
|
|
||||||
<em>No entries.</em>
|
|
||||||
@endforelse
|
|
||||||
</div>
|
|
||||||
@endforeach
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,8 @@ Route::get('/dashboard', function () {
|
||||||
return view('dashboard');
|
return view('dashboard');
|
||||||
})->middleware(['auth'])->name('dashboard');
|
})->middleware(['auth'])->name('dashboard');
|
||||||
|
|
||||||
Route::resource('foods', FoodController::class);
|
Route::resource('foods', FoodController::class)->middleware(['auth']);
|
||||||
Route::resource('recipes', RecipeController::class);
|
Route::resource('recipes', RecipeController::class)->middleware(['auth']);
|
||||||
Route::resource('journal-entries', JournalEntryController::class);
|
Route::resource('journal-entries', JournalEntryController::class)->middleware(['auth']);
|
||||||
|
|
||||||
require __DIR__.'/auth.php';
|
require __DIR__.'/auth.php';
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue