Convert json String into Object of custom class instead of stdClass.
问题 my order.php file has /** * Encode the cart items from json to object * @param $value * @return mixed */ public function getCartItemsAttribute($value){ return json_decode($value); } And in my controller i fetch cartItems as follows public function orderDetails(Order $order){ $address = implode(',',array_slice((array)$order->address,2,4)); foreach ($order->cartItems as $item){ dd($item); } return view('/admin/pages/productOrders/orderDetails',compact('order','address')); } And in above code dd