WIP
This commit is contained in:
@@ -30,9 +30,8 @@ class CartController extends Controller
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return response()->rest(
|
||||
$cartItems->map(fn ($cartItem) => [
|
||||
|
||||
$data = $cartItems->map(fn ($cartItem) => [
|
||||
'id' => $cartItem->id,
|
||||
'user_id' => $cartItem->user_id,
|
||||
'product_id' => $cartItem->product_id,
|
||||
@@ -40,7 +39,18 @@ class CartController extends Controller
|
||||
'created_at' => $cartItem->created_at,
|
||||
'updated_at' => $cartItem->updated_at,
|
||||
'product' => new ProductResource($cartItem->product),
|
||||
])
|
||||
])->groupBy(function (array $cartItem) {
|
||||
if (isset($cartItem['product']) && $cartItem['product']->channels->count() > 0) {
|
||||
return $cartItem['product']->channels[0]->slug;
|
||||
}
|
||||
|
||||
return 'default';
|
||||
});
|
||||
|
||||
return response()->rest(
|
||||
$data,
|
||||
code: 200,
|
||||
message: 'Cart items'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user