Do you want to show all four shopping carts' contents together in the same view template??? Or do you want to simply show the Cart that belongs to the current Session?
Oct 19, 2022
5
Level 6
How can we display the contents and products inside the four carts?
We have a uuid column in the factors table, which is the uuid value At Each shopping cart is fixed.
If we want to display each shopping cart based on the uuid table. For example, there are twenty ids in the table that are related to four shopping carts. How can we display the contents and products inside the 6 factors?
data https://postimg.cc/7GqbZ44j
show https://postimg.cc/phMzQ3HB
Controller
$bill = Faktor::selectRaw('user_id, sum(price * quantity) as total, count(*) as count')
->groupBy('uuid')
->get();
return view('home',compact('bill',
View
@foreach($bill as $name)
@if($loop->first)
<div class="col-lg-2 col-md-6 col-sm-12">
<a class="noline text-light" href="{{ route('person',$name->uuid) }}">
<p class="text-light"><i class="bx bx-user"></i>{{ $name->user_id }}</p>
</a>
<p class="text-light"><i class="bx bx-user"></i>{{ $name->price}}</p>
</div>
@endif
@endforeach
```
Level 104
@LoverCode you can make a query to fetch each Cart's total, count and user_id like this - I have shown a commented line where the user relationship is eager-loaded (if needed):
$carts = Faktor::selectRaw('user_id, sum(price * quantity) as total, count(*) as count')
// ->with('user')
->groupBy('uuid')
->get();
1 like
Please or to participate in this conversation.