【发布时间】:2019-04-22 08:18:06
【问题描述】:
我必须将 product 表中的 purchase_prices 字段传递到 crinsane 购物车,以便我可以从每笔交易中看到 profit 并将其保存到数据库中。
这是我在 CartController
上的代码$product = Product::find($id);
Cart::add([
'id' => $product->id,
'name' => $product->name,
'qty' => 1,
'price' => $product->sell_price,
'options' => ['purchase' => $product->purchase_price]
]);
return back();
但购买未存储
Collection {#257 ▼
#items: array:1 [▼
"370d08585360f5c568b18d1f2e4ca1df" => CartItem {#258 ▼
+rowId: "370d08585360f5c568b18d1f2e4ca1df"
+id: 2
+qty: 1
+name: "Beras B"
+price: 12000.0
+weight: 1.0
+options: CartItemOptions {#259 ▼
#items: []
}
-associatedModel: null
-taxRate: 0
-discountRate: 0
}
]
}
【问题讨论】:
-
Cart::add 是否接受数组作为值>?
标签: laravel shopping-cart laravel-5.8