Open mrdigitalau opened 6 years ago
Here maybe a solution : Build a class "Transformer" so you can map Cart::content and for each item transform it to your product model, Like this,
$products = Cart::content()->each(function($item){
$product = new Product;
$product->id = $item->id;
..
return $product;
});
$productIds = Cart::content()->pluck('id');
$products = Product::query()->whereIn('id', $productIds)->get();
// OR
$products = Product::find($productIds);
Hi,
Thank you for building this, it has saved me tonnes of time.
I'm using Laravel and VueJS, I am passing the cart object into VUE to show the cart, is there any way to eager load the model associated with the cart item because I can't find a way to pass the model information into Vue?
Something like Cart::content()->with('Product')
Or similar?
Cheers