From 5152019e61c872dc1ae8ee1fd40cd686d0fd4240 Mon Sep 17 00:00:00 2001 From: faiqahzaman <91926774+faiqahzaman@users.noreply.github.com> Date: Wed, 26 Jan 2022 09:55:56 +0800 Subject: [PATCH] search lelong details by cawangan id --- .../AuthMobile/LelongMobileController.php | 34 +++++++++++++++++++ routes/api.php | 1 + 2 files changed, 35 insertions(+) diff --git a/app/Http/Controllers/AuthMobile/LelongMobileController.php b/app/Http/Controllers/AuthMobile/LelongMobileController.php index 6c1c7202..593cc723 100644 --- a/app/Http/Controllers/AuthMobile/LelongMobileController.php +++ b/app/Http/Controllers/AuthMobile/LelongMobileController.php @@ -115,4 +115,38 @@ class LelongMobileController extends Controller return response()->json($lelongbidder); } + + public function searchLelByCaw(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) + ->get()->toArray(); + + foreach($lelong as $index1=>$lel) + { + $lelongbid = LelongBid::where('lelong_id',$lel['lelong_id']) + ->get()->toArray(); + + $lelong[$index1]['lelongbid'] = $lelongbid; + + foreach($lelongbid as $index2=>$lelbidmarhun){ + $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; + } + + } + + return response()->json($lelong); + } } diff --git a/routes/api.php b/routes/api.php index e95749ee..980ca988 100644 --- a/routes/api.php +++ b/routes/api.php @@ -52,6 +52,7 @@ Route::group(['middleware' => ['auth:sanctum']], function () { // Lelong Route::get('/lelongDetails/today', [LelongMobileController::class, 'getlelongdetails']); + Route::get('/lelongDetails/cawangan', [LelongMobileController::class, 'searchLelByCaw']); Route::get('/karat', [LelongMobileController::class, 'getListKarat']); // Lelong => Bidder