get lelong details & get list karat

This commit is contained in:
faiqahzaman
2022-01-23 16:02:04 +08:00
parent 073cf456cf
commit 62899b4d55
4 changed files with 116 additions and 39 deletions
@@ -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);
}
}
@@ -0,0 +1,53 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateLelongbidderTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('lelongbidder', function (Blueprint $table) {
$table->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');
}
}
+3 -2
View File
@@ -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']);
});
+6
View File
@@ -1,6 +1,7 @@
<?php
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Http;
/*
|--------------------------------------------------------------------------
@@ -17,6 +18,11 @@ Route::get('/', function () {
return view('welcome');
})->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');