I've encountered this problem (
Cannot use object of type __PHP_Incomplete_Class as array
) while doing an e-commerce site using Laravel, I tried to get the name of the purchased products. My controller function is this
$orders=Auth::user()->orders;
$orders->transform(function($orders, $key) { $orders->cart=unserialize($orders->cart);
return $orders;
});return view('shop.profile', ['orders'=>$orders]);
The problem in the view code is this exact line {{$item['item']['name']}}, without it, i can see the quantity puchased, the price and anything else.
I've done everything I knew and found on the internet, but didn't find any solution
<h2 align="center">My orders</h2> <br/> @foreach($orders as $order) <div class="panel panel-default"> <div class="panel-body"> <ul class="list-group"> @foreach($order->cart->items as $item) <li class="list-group-item"> <span class="badge">{{$item['price']}} lei</span> {{$item['item']['name']}} | {{$item['qty']}} </li> @endforeach </ul> </div> <div class="panel-footer"><strong>Total Price: {{$order->cart->totalPrice}} lei </strong></div> </div> @endforeach- Sandra