Skip to content

Commit

Permalink
lang and total shopping cart
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathanbees committed Nov 19, 2024
1 parent 9e6aaef commit 4e8fb02
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
5 changes: 5 additions & 0 deletions app/Http/Controllers/GameController.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,13 @@ public function shoppingCart(): View
$cart = session()->get('cart', []);
$games = Game::find($cart);

$totalPrice = $games->sum(function ($game) {
return $game->getPrice();
});

$viewData = [];
$viewData['games'] = $games;
$viewData['totalPrice'] = $totalPrice;

return view('game.shoppingCart')->with('viewData', $viewData);
}
Expand Down
3 changes: 2 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -342,5 +342,6 @@
"Add to cart (Functionality Coming Soon)": "Add to cart (Functionality Coming Soon)",
"Description": "Description",
"Warranty": "Warranty",
"Years": "Years"
"Years": "Years",
"Partner Products": "Partner Products"
}
3 changes: 2 additions & 1 deletion lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -342,5 +342,6 @@
"Add to cart (Functionality Coming Soon)": "Agregar al carrito (Funcionalidad próximamente)",
"Description": "Descripción",
"Warranty": "Garantía",
"Years": "Años"
"Years": "Años",
"Partner Products": "Productos aliados"
}
7 changes: 7 additions & 0 deletions resources/views/game/shoppingCart.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@
</div>
</a>
@endforeach
<div class="list-group-item list-group-item-action">
<div class="d-flex justify-content-between align-items-center">
<h5 class="mb-1">{{ __('Total') }}</h5>
<strong class="text-muted"></strong>
<strong class="text-muted">{{ $viewData['totalPrice'] }}$</strong>
</div>
</div>
</div>
@else
<h1 class="text-center">{{ __('Your shopping cart is empty.') }}</h1>
Expand Down

0 comments on commit 4e8fb02

Please sign in to comment.