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?
Hello, first why are you using session cart with database,
you can use https://github.com/Crinsane/LaravelShoppingcart package that has a lot of required functions, and second, instead of DB use eloquent that will be much easier to figure out the problem