Level 9
You need to give total a key:
return view('stripe/stripe', ['items' => $items, 'total' => $total]);
Cheers, Adam
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I want to pass a simple sum of a column to my view.
I have my controller that grabs the items a person won in an auction. I then sum the total due. I then pass it to the view, but all I get is an error and it seems like it should be silly simple, but my brain is broken today.
public function stripe()
{
$user = Auth::user();
$items = Item::where('event_id', session('selected_event'))
->where('current_bidder', $user->id)
->where('sold', 1)
->get();
$total = Item::where('event_id', session('selected_event'))
->where('current_bidder', $user->id)
->where('sold', 1)
->sum('current_bid');
//dd($items, $total);
return view('stripe/stripe', ['items' => $items, $total]);
}
The value '115' is the correct sum.
Illuminate\Database\Eloquent\Collection {#1308 ▼
#items: array:2 [▶]
}
"115"
<div class="card-footer">
<h5>Total Amount Due: ${{ $total }}.00</h5>
</div>
You need to give total a key:
return view('stripe/stripe', ['items' => $items, 'total' => $total]);
Cheers, Adam
Please or to participate in this conversation.