Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ThyagoSB's avatar

Session of a shopping cart

Good afternoon. Could someone help me with a shopping cart. I'm trying to do this.

$qtd = $request->input('qtd'); $produtos = DB::select('select nome from produtos where id = ?',[$id]); session()->push('sessao_carrinho', $produtos, $qtd);

and in the view

@foreach(Session::get('sessao_carrinho') as $carrinho) {{$carrinho->nome}}{{$carrinho->qtd}} @endforeach

but from this error.

Trying to get property of non-object (View: C:\Program

Can someone tell me if I'm doing it right, or do you have any idea how I can make this cart?

0 likes
1 reply

Please or to participate in this conversation.