search lelong details by cawangan id

This commit is contained in:
faiqahzaman
2022-01-26 09:55:56 +08:00
parent ecc9393cf7
commit 5152019e61
2 changed files with 35 additions and 0 deletions
@@ -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);
}
}
+1
View File
@@ -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