fix api select senarai exclude in cart&bidRecord
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user