WIP
This commit is contained in:
1 parent
ba9402afb0
commit
9f27fe260e
1 file changed
+14
-4
@@ -30,9 +30,8 @@ public function index(): JsonResponse
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
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 @@ public function index(): JsonResponse
|
||||
'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