I saved my cart data to the orders
table with the serialize
method, now in my orders 'view' page, I want to display them to the user to show their order history.
How can I revert the previously serialized data to usable objects/arrays within PHP?
The code snippet of where I save the data: $order->cart = serialize($cartItems);
.
The method I try to return my orders index view:
/**
* Action to receive all orders from the current
* logged-in user. This action will return the
* 'front.orders' view with the orders compacted inside.
*
* @return orders view
*/
public function orders() {
// get the orders from the current logged in user
$orders = Order::where('user_id', '=', Auth::user()->id)->get();
// view the `front.orders` page passing in the `orders` variable
return view('front.orders', compact('orders'));
}