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($item) will outputs as follows
{#422 ▼
+"id": 4
+"user_id": 2
+"product_id": 1
+"quantity": 1
+"deleted_at": null
+"created_at": "2018-02-16 08:12:08"
+"updated_at": "2018-02-16 08:12:08"
}
but I want as below.
Cart {#422 ▼
+"id": 4
+"user_id": 2
+"product_id": 1
+"quantity": 1
+"deleted_at": null
+"created_at": "2018-02-16 08:12:08"
+"updated_at": "2018-02-16 08:12:08"
}
How can i achieve this in laravel.