fix api select senarai exclude in cart&bidRecord

This commit is contained in:
Amir
2022-08-21 00:09:13 +08:00
parent 615894d426
commit 8c93f80be6
3 changed files with 220 additions and 9 deletions
+39
View File
@@ -53,6 +53,45 @@ class CartController extends Controller
return response()->json($carts);
}
public function getCartByCawangan($userId)
{
$groupCawangan = Cart::join('lelongbid', 'carts.lelongbid_id', '=', 'lelongbid.id')
->join('cawangan', 'lelongbid.caw_id', '=', 'cawangan.id')
->where('user_id', '=', $userId)
->select('caw_id', 'caw_name')
->groupBy('caw_id')
->get()->toArray();
foreach ($groupCawangan as $index => $cawangan) {
$cart = Cart::join('lelongbid', 'carts.lelongbid_id', '=', 'lelongbid.id')
->where('user_id', $userId)
->where('caw_id', $cawangan)
->get()->toArray();
foreach ($cart as $index1 => $data) {
$marhun = LelongBidMarhun::where('lelongbid_id', '=', $data['id'])->get()->toArray();
$cart[$index1]['lelongbidmarhun'] = $marhun;
}
$groupCawangan[$index]['lelongbid'] = $cart;
}
if ($groupCawangan) {
return response()->json([
'success' => true,
'cart' => $groupCawangan
], 201);
} else {
return response()->json([
'success' => false,
'message' => 'Empty Data'
], 201);
}
}
public function addToCart(Request $request)
{
$item = new Cart;