fix api select cawangan

This commit is contained in:
Amir
2022-06-22 07:25:33 +08:00
parent 4b176eb3d1
commit b14795f31f
2 changed files with 101 additions and 3 deletions
@@ -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"
]);
}
}
+2
View File
@@ -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']);