diff --git a/app/Http/Controllers/Mobile/LelongMobileController.php b/app/Http/Controllers/Mobile/LelongMobileController.php index a7bed2f9..f2e69209 100644 --- a/app/Http/Controllers/Mobile/LelongMobileController.php +++ b/app/Http/Controllers/Mobile/LelongMobileController.php @@ -221,29 +221,91 @@ class LelongMobileController extends Controller $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) ->get()->toArray(); $lelong[$index1]['lelongbid'] = $lelongbid; foreach($lelongbid as $index2=>$lelbidmarhun){ - $cawangan = Cawangan::where('id','=',$lelbidmarhun['caw_id'])->first()->toArray(); + // $cawangan = Cawangan::where('id','=',$lelbidmarhun['caw_id'])->first()->toArray(); // $id = lelongbid::first(); $lelongbidmarhun = LelongBidMarhun::where('lelongbid_id', $lelbidmarhun['id']) ->get()->toArray(); $lelong[$index1]['lelongbid'][$index2]['lelongbidmarhun'] = $lelongbidmarhun; - $lelong[$index1]['lelongbid'][$index2]['cawangan'] = $cawangan; + // $lelong[$index1]['lelongbid'][$index2]['cawangan'] = $cawangan; } } - return response()->json($lelong); + 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(); + $currentdate = $currentdate->toDateString(); + + // $arrayLelong = []; + $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(); + dd($lelong); + + + foreach($lelong as $index1 => $lel) + { + $lelongbid = LelongBid ::where('lelong_id', $lel['lelong_id']) + ->where('caw_id', '=', $request->caw_id) + ->get()->toArray(); + + $lelong[$index1]['lelongbid'] = $lelongbid; + // dd($lelong); + + + + foreach($lelongbid as $index=>$lelbidmarhun){ + // $cawangan = Cawangan::where('id','=',$lelbidmarhun['caw_id'])->first()->toArray(); + // $id = lelongbid::first(); + + $lelongbidmarhun = LelongBidMarhun::where('lelongbid_id', $lelbidmarhun['id']) + ->get()->toArray(); + + $lelong['lelongbid'][$index]['lelongbidmarhun'] = $lelongbidmarhun; + // $lelong[$index1]['lelongbid'][$index2]['cawangan'] = $cawangan; + // dd($lelong); + } + } + + if($lelong) { + return response()->json( + ['success' => true, 'message' => $lelong], 201 + ); + } + else { + return response()->json( + ['success' => false, 'message' => 'Empty Data'], 201 + ); + } + } public function bidresult($user_id) @@ -434,6 +496,38 @@ class LelongMobileController extends Controller $lelong = Lelong::join('cawangan_lelong', 'lelong.id', '=', 'cawangan_lelong.lelong_id') ->join('cawangan', 'cawangan_lelong.caw_id', '=', 'cawangan.id') ->where('tarikh_lelong', '=', $currentdate) + ->select( + 'lelong.id as lelong_id', + 'lelong.tarikh_lelong', + 'cawangan.caw_name', + 'cawangan_lelong.caw_id', + 'cawangan_lelong.masamula_lelong', + 'cawangan_lelong.masatamat_lelong', + ) + ->get()->toArray(); + + if ($lelong) { + return response()->json([ + 'success' => true, + 'lelong' => $lelong + ]); + } else { + return response()->json([ + 'success' => false, + ]); + } + } + + public function listCawLelongTodayStarted() + { + + $currentdate = Carbon::now(); + $currentdate = $currentdate->toDateString(); + + $lelong = Lelong::join('cawangan_lelong', 'lelong.id', '=', 'cawangan_lelong.lelong_id') + ->join('cawangan', 'cawangan_lelong.caw_id', '=', 'cawangan.id') + ->where('tarikh_lelong', '=', $currentdate) + ->where('cawangan_lelong.status_online', 1) ->select( 'lelong.id as lelong_id', 'lelong.tarikh_lelong', @@ -443,6 +537,7 @@ class LelongMobileController extends Controller 'lelong.masatamat_lelong', ) ->get()->toArray(); + // dd($lelong); if ($lelong) { return response()->json([ @@ -484,6 +579,7 @@ class LelongMobileController extends Controller } else { return response()->json([ 'success' => false, + 'message' => "Empty Data" ]); } } diff --git a/routes/api.php b/routes/api.php index 30a17f72..0bddcfe2 100644 --- a/routes/api.php +++ b/routes/api.php @@ -57,11 +57,13 @@ Route::group(['middleware' => ['auth:sanctum']], function () { // Lelong Route::get('/lelongDetails/today', [LelongMobileController::class, 'getlelongdetails']); Route::get('/lelongDetails/cawangan', [LelongMobileController::class, 'searchLelByCaw']); + Route::get('/lelong/cawangan', [LelongMobileController::class, 'searchLelongByCawangan']); Route::get('/karat', [LelongMobileController::class, 'getListKarat']); Route::get('/result/{user_id}', [LelongMobileController::class, 'bidresult']); Route::get('/bayar/{user_id}/{lelong_id}', [LelongMobileController::class, 'bidresults']); Route::get('/history/{user_id}', [LelongMobileController::class, 'history']); Route::get('/listcawlelongtoday', [LelongMobileController::class, 'listCawLelongToday']); + Route::get('/listcawlelongtodaystarted', [LelongMobileController::class, 'listCawLelongTodayStarted']); Route::get('/listcawlelongnext', [LelongMobileController::class, 'listCawLelongNext']); Route::post('/bayarcdm', [LelongMobileController::class, 'bayarCdm']);