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;
@@ -170,6 +170,44 @@ class LelongMobileController extends Controller
return response()->json($lelongbidder);
}
public function bidRecordByCawangan($userId, Request $request)
{
$groupCawangan = LelongBidder::join('lelongbid', 'lelongbidder.lelongbid_id', '=', 'lelongbid.id')
->join('cawangan', 'lelongbid.caw_id', '=', 'cawangan.id')
->where('user_id', '=', $userId)
->where('lelong_id', $request->lelongId)
->select('caw_id', 'caw_name')
->groupBy('caw_id')
->get()->toArray();
foreach ($groupCawangan as $index => $cawangan) {
$lelongBidder = LelongBidder::join('lelongbid', 'lelongbidder.lelongbid_id', '=', 'lelongbid.id')
->where('user_id', $userId)
->where('caw_id', $cawangan)
->get()->toArray();
foreach ($lelongBidder as $index1 => $data) {
$marhun = LelongBidMarhun::where('lelongbid_id', '=', $data['id'])->get()->toArray();
$lelongBidder[$index1]['lelongbidmarhun'] = $marhun;
}
$groupCawangan[$index]['lelongbid'] = $lelongBidder;
}
if ($groupCawangan) {
return response()->json([
'success' => true,
'lelongbidder' => $groupCawangan
], 201);
} else {
return response()->json([
'success' => false,
'message' => 'Empty Data'
], 201);
}
}
// please do not delete this changes
// backup web pembida
public function listBidItemWeb($user_id, Request $request){
@@ -274,6 +312,66 @@ class LelongMobileController extends Controller
}
}
public function listSuratLelong(Request $request)
{
$currentdate = Carbon::now();
$currentdate = $currentdate->toDateString();
$lelong = Lelong::join('cawangan_lelong', 'lelong.id', '=', 'cawangan_lelong.lelong_id')
->where('tarikh_lelong', '=', $currentdate)
->where('caw_id', '=', $request->caw_id)
->where('status_online', '=', 1)
->get()->toArray();
foreach ($lelong as $index1 => $lel) {
$lelongbid = LelongBid::where('lelong_id', $lel['lelong_id'])
->where('caw_id', '=', $request->caw_id)
->select('id', 'kodcaw')
->get();
$pluckedLelongBid = $lelongbid->pluck('id')->toArray();
$carts = Cart::where('user_id', $request->user_id)
->select('lelongbid_id')
->get();
$pluckedCarts = $carts->pluck('lelongbid_id')->toArray();
$lelongbidder = LelongBidder::join('lelongbid', 'lelongbidder.lelongbid_id', "=", 'lelongbid.id')
->where('lelong_id', $request->lelong_id)
->where('user_id', $request->user_id)
->select('lelongbid_id')
->get();
$pluckedLelongBidder = $lelongbidder->pluck('lelongbid_id')->toArray();
$arrayDiff1 = array_diff($pluckedLelongBid, $pluckedCarts);
$arrayDiff2 = array_diff($arrayDiff1, $pluckedLelongBidder);
$listLelong = [];
foreach ($arrayDiff2 as $index => $data) {
$lelongbid = LelongBid::where('id', $data)->first()->toArray();
$lelongbidmarhun = LelongBidMarhun::where('lelongbid_id', $lelongbid['id'])->get()->toArray();
$lelongbid['lelongbidmarhun'] = $lelongbidmarhun;
array_push($listLelong, $lelongbid);
$lelong[$index1]['lelongbid'] = $listLelong;
}
}
if ($lelong) {
return response()->json(
['success' => true, 'message' => $lelong],
201
);
} else {
return response()->json(
['success' => false, 'message' => 'Empty Data'],
201
);
}
}
public function searchLelongByCawangan(Request $request){
$currentdate = Carbon::now();
@@ -922,4 +1020,38 @@ class LelongMobileController extends Controller
]);
}
}
public function resultStatus($userId, $lelongId)
{
// dd('hey');
$lelong = Lelong::join('lelongbid', 'lelong.id', '=', 'lelongbid.lelong_id')
->join('lelongbidder', 'lelongbid.id', '=', 'lelongbidder.lelongbid_id')
->where('lelongbidder.user_id', $userId)
->where('lelong.id', $lelongId)
->where('status_bidder', 1)
->get();
foreach ($lelong as $index) {
$status = true;
if ($index->status_payment == null || $index->status_payment == 0) {
$status = false;
}
}
if ($lelong) {
return response()->json([
'success' => true,
'statusMenang' => true,
'statusBayaran' => $status,
]);
} else {
return response()->json([
'success' => false,
'statusMenang' => false,
]);
}
}
}