【发布时间】:2018-06-15 23:48:33
【问题描述】:
我使用serialize 方法将我的购物车数据保存到orders 表中,现在在我的订单“查看”页面中,我想向用户显示他们的订单历史记录。
如何在 PHP 中将之前序列化的数据恢复为可用的对象/数组?
我保存数据的位置的代码 sn-p:$order->cart = serialize($cartItems);。
我尝试返回订单索引视图的方法:
/**
* 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'));
}
【问题讨论】:
标签: php laravel serialization