From c12796cb28c0e7d24b2d797b56fb915d36bf2ce3 Mon Sep 17 00:00:00 2001 From: "Christopher C. Wells" Date: Tue, 29 Dec 2020 10:33:36 -0800 Subject: [PATCH] Add Ingredients index view --- app/Http/Controllers/IngredientController.php | 9 ++-- resources/views/ingredients/index.blade.php | 54 +++++++++++++++++++ resources/views/layouts/navigation.blade.php | 31 +++++++++-- 3 files changed, 86 insertions(+), 8 deletions(-) create mode 100644 resources/views/ingredients/index.blade.php diff --git a/app/Http/Controllers/IngredientController.php b/app/Http/Controllers/IngredientController.php index 9b6e9da..a0ce9af 100644 --- a/app/Http/Controllers/IngredientController.php +++ b/app/Http/Controllers/IngredientController.php @@ -12,11 +12,12 @@ class IngredientController extends Controller /** * Display a listing of the resource. * - * @return \Illuminate\Http\Response + * @return \Illuminate\Contracts\View\View */ - public function index() + public function index(): View { - // + return view('ingredients.index') + ->with('ingredients', Ingredient::all()->sortBy('name')); } /** @@ -29,7 +30,7 @@ class IngredientController extends Controller return view('ingredients.create'); } - /** + /**newly * Store a newly created resource in storage. */ public function store(Request $request): RedirectResponse diff --git a/resources/views/ingredients/index.blade.php b/resources/views/ingredients/index.blade.php new file mode 100644 index 0000000..5d2edc3 --- /dev/null +++ b/resources/views/ingredients/index.blade.php @@ -0,0 +1,54 @@ + + +

+ {{ __('List Ingredients') }} +

+
+ +
+
+ @if(session()->has('message')) +
+ {{ session()->get('message') }} +
+ @endif +
+
+
+ @foreach ($ingredients as $ingedient) +
+
+
+ {{ $ingedient->name }}@if($ingedient->detail), {{ $ingedient->detail }}@endif +
+
+ @if ($ingedient->unit_weight) + {{ $ingedient->unit_weight }}g each + @else + {{ $ingedient->cup_weight }}g per cup + @endif +
+
+
+
Amount per 100g
+
Calories
+
{{$ingedient->calories}}
+
Fat
+
{{ $ingedient->fat < 1 ? $ingedient->fat * 1000 . "m" : $ingedient->fat }}g
+
Cholesterol
+
{{ $ingedient->cholesterol < 1 ? $ingedient->cholesterol * 1000 . "m" : $ingedient->cholesterol }}g
+
Sodium
+
{{ $ingedient->sodium < 1 ? $ingedient->sodium * 1000 . "m" : $ingedient->sodium }}g
+
Carbohydrates
+
{{ $ingedient->carbohydrates < 1 ? $ingedient->carbohydrates * 1000 . "m" : $ingedient->carbohydrates }}g
+
Protein
+
{{$ingedient->protein}}g
+
+
+ @endforeach +
+
+
+
+
+
diff --git a/resources/views/layouts/navigation.blade.php b/resources/views/layouts/navigation.blade.php index 89c9645..a19db08 100644 --- a/resources/views/layouts/navigation.blade.php +++ b/resources/views/layouts/navigation.blade.php @@ -16,10 +16,33 @@ {{ __('Dashboard') }} -