diff --git a/app/Http/Controllers/AuthMobile/LelongMobileController.php b/app/Http/Controllers/AuthMobile/LelongMobileController.php index 1b2e6169..2ecee188 100644 --- a/app/Http/Controllers/AuthMobile/LelongMobileController.php +++ b/app/Http/Controllers/AuthMobile/LelongMobileController.php @@ -7,6 +7,7 @@ use Illuminate\Http\Request; use App\Models\Lelong; use App\Models\LelongBid; use App\Models\LelongBidMarhun; +use App\Models\lelkarat; use Carbon\Carbon; class LelongMobileController extends Controller @@ -53,11 +54,8 @@ class LelongMobileController extends Controller $currentdate = Carbon::now(); $currentdate = $currentdate->toDateString(); - $lelong = Lelong::where('tarikh_lelong','=',$currentdate)->get(); - - $arrayLelong = []; - $lelong = Lelong::where('tarikh_lelong','=',$currentdate)->get(); - + // $arrayLelong = []; + $lelong = Lelong::where('tarikh_lelong','=',$currentdate)->get()->toArray(); // $lelongbid = LelongBid::where('t_lelong', '=', $currentdate) // ->select('lelong_id', // 'id as lelongbid_id', @@ -85,41 +83,60 @@ class LelongMobileController extends Controller // 'status_payment') // ->get(); - $lelongbid = LelongBid::whereIn('lelong_id',$arrayLelong) - ->select('lelong_id', - 'id as lelongbid_id', - 'caw_id', - 'kodcaw', - 'norujukan', - 't_lelong as tarikh_lelong', - 'hargaasas', - 'hargajual', - 't_jual', - 'nopembeli', - 'jbg', - 'kadarupah', - 'upahsimpan', - 'ansuran', - 'pinjaman', - 'bakiupah', - 'cajlain', - 'cajlelong', - 'baki', - 'gst_hj', - 'gst_cl', - 'percent', - 'status_jual', - 'status_payment') - ->union($lelong) - ->get(); + foreach($lelong as $index1=>$lel) + { + $lelongbid = LelongBid::whereIn('lelong_id',$lelong) + ->select('lelong_id', + 'id as lelongbid_id', + 'caw_id', + 'kodcaw', + 'norujukan', + 't_lelong as tarikh_lelong', + 'hargaasas', + 'hargajual', + 't_jual', + 'nopembeli', + 'jbg', + 'kadarupah', + 'upahsimpan', + 'ansuran', + 'pinjaman', + 'bakiupah', + 'cajlain', + 'cajlelong', + 'baki', + 'gst_hj', + 'gst_cl', + 'percent', + 'status_jual', + 'status_payment') + // ->union($lelong) + ->get()->toArray(); - $lelongbidmarhun = LelongBidMarhun::join('lelongbid', 'lelongbidmarhun.lelongbid_id', '=', 'lelongbid.id') - ->get(); + $lelongbidmarhun = LelongBidMarhun::join('lelongbid', 'lelongbidmarhun.lelongbid_id', '=', 'lelongbid.id') + ->get()->toArray(); - - array_push($arrayLelong,['lelong' => $lelong,'lelong_bid' => $lelongbid, 'lelong_bid_marhun' => $lelongbidmarhun]); + $lelong[$index1]['lelongbid'] = $lelongbid; + $lelong[$index1]['lelongbid']['lelongbidmarhun'] = $lelongbidmarhun; + // array_push($lelong[$index1],'lelongzz','lasdsa'); + + + + + // array_push($lelong[$index1],['lelong_bid' => $lelongbid[0], 'lelong_bid_marhun' => $lelongbidmarhun]); + } + + return response()->json($lelong); - return response()->json($arrayLelong); + } + + public function getListKarat(Request $request){ + + $getKarat = lelkarat::all(); + + // $user = User::all(); + + return response()->json($getKarat); } } diff --git a/database/migrations/2022_01_23_042652_create_lelongbidder_table.php b/database/migrations/2022_01_23_042652_create_lelongbidder_table.php new file mode 100644 index 00000000..99e77450 --- /dev/null +++ b/database/migrations/2022_01_23_042652_create_lelongbidder_table.php @@ -0,0 +1,53 @@ +bigIncrements('id'); + $table->unsignedBigInteger('user_id')->unsigned(); + $table->integer('lelongbid_id'); + $table->string('nama_bidder'); + $table->decimal('hargabida'); + $table->integer('nosirilel'); + $table->datetime('t_lelong'); + $table->integer('nopembeli'); + $table->decimal('nilaimarhun'); + $table->decimal('cajlelong'); + $table->integer('status_bidder'); + $table->integer('status_bidder_win'); + $table->integer('status_payment'); + $table->datetime('masa_bidaan'); + $table->integer('status_jual')->nullable(); + $table->string('tempstatus_bidder'); + $table->datetime('deleted_at')->nullable(); + $table->integer('deleted_by')->nullable(); + $table->timestamps(); + + + $table->foreign('user_id') + ->references('id')->on('users') + ->onDelete('cascade'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('lelongbidder'); + } +} diff --git a/routes/api.php b/routes/api.php index c8537bd8..f106f8ed 100644 --- a/routes/api.php +++ b/routes/api.php @@ -37,9 +37,10 @@ Route::group(['middleware' => ['auth:sanctum']], function () { Route::post('/reset', [NewPasswordController::class, 'reset']); Route::get('/user/profile', [UserController::class, 'getProfileUser']); Route::put('/userUpdate/profile', [UserController::class, 'updateProfileUser']); - Route::get('/details/lelong', [LelongMobileController::class, 'listLelongDetails']); + // Route::get('/details/lelong', [LelongMobileController::class, 'listLelongDetails']); Route::get('/lelongDetails/today', [LelongMobileController::class, 'getlelongdetails']); - + Route::get('/karat', [LelongMobileController::class, 'getListKarat']); + }); diff --git a/routes/web.php b/routes/web.php index 3d56d08e..2dc0c6b7 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,6 +1,7 @@ name('login'); +Route::get('/test', function () { + $response = Http::get('http://localhost:8000/api/lelongDetails/today')->json(); + dd($response); +})->name('test'); + Auth::routes(); Route::get('/home','HomeController@index')->name('home');