From 3d614dd677c10b8d88f05621b08a011310463be0 Mon Sep 17 00:00:00 2001 From: Amir Date: Fri, 4 Nov 2022 22:16:46 +0800 Subject: [PATCH] Fix payment migration --- app/Http/Controllers/ApiController.php | 1 + .../Mobile/LelongMobileController.php | 1 + app/Http/Controllers/SimulasiController.php | 4 +- app/Models/Lelong.php | 2 +- ...2022_01_25_010223_create_payment_table.php | 105 ++++++++++-------- .../views/lelong/senarailelong.blade.php | 2 +- 6 files changed, 66 insertions(+), 49 deletions(-) diff --git a/app/Http/Controllers/ApiController.php b/app/Http/Controllers/ApiController.php index 204fb6a9..7bfd657e 100644 --- a/app/Http/Controllers/ApiController.php +++ b/app/Http/Controllers/ApiController.php @@ -414,6 +414,7 @@ class ApiController extends Controller $payment->user_id = $request->user_id; $payment->lelong_id = $request->lelong_id; $payment->kodcaw = $index['kodcaw']; + $payment->lelongbid_id = $index['lelongbid_id']; $payment->norujukan = $index['norujukan']; $payment->total_payment = $index['total_payment']; $payment->status_payment_opt = 2; //bayar secara online 2 diff --git a/app/Http/Controllers/Mobile/LelongMobileController.php b/app/Http/Controllers/Mobile/LelongMobileController.php index 72a54180..f9974244 100644 --- a/app/Http/Controllers/Mobile/LelongMobileController.php +++ b/app/Http/Controllers/Mobile/LelongMobileController.php @@ -583,6 +583,7 @@ class LelongMobileController extends Controller ->where('lelongbid.kodcaw', $kodcaw->kodcaw) ->select( 'lelongbidder.id AS id', + 'lelongbid.id AS lelongbid_id', 'lelongbid.norujukan AS norujukan', 'lelongbid.kodcaw AS kodcaw', 'lelongbidder.hargabida AS total_payment', diff --git a/app/Http/Controllers/SimulasiController.php b/app/Http/Controllers/SimulasiController.php index ea3d6215..21bffc53 100644 --- a/app/Http/Controllers/SimulasiController.php +++ b/app/Http/Controllers/SimulasiController.php @@ -943,9 +943,9 @@ class SimulasiController extends Controller public function show($id) { $simulasi_id = $id; - $simulasi = Simulasi::with(['cawangan', 'simulasiBid.simulasiBidMarhun'])->where('id', '=', $id)->first(); + $simulasi = Simulasi::with(['cawangan', 'simulasiBid.simulasiBidMarhun', 'simkarat'])->find($id); $data = $simulasi; - $simkarat = SimKarat::where('simulasi_id', '=', $id)->get(); + $simkarat = $simulasi->simkarat; $jeniskarat = JenisKarat::all(); $cawanganAll = $simulasi->cawangan; diff --git a/app/Models/Lelong.php b/app/Models/Lelong.php index d3bee12d..60476570 100644 --- a/app/Models/Lelong.php +++ b/app/Models/Lelong.php @@ -23,7 +23,7 @@ class Lelong extends Model public function cawangan() { - return $this->belongsToMany(Cawangan::class, 'cawangan_lelong', 'lelong_id', 'caw_id'); + return $this->belongsToMany(Cawangan::class, 'cawangan_lelong', 'lelong_id', 'caw_id')->withPivot('export_data_sts'); } public function cawanganLelong() diff --git a/database/migrations/2022_01_25_010223_create_payment_table.php b/database/migrations/2022_01_25_010223_create_payment_table.php index fc3eea2e..cf46add8 100644 --- a/database/migrations/2022_01_25_010223_create_payment_table.php +++ b/database/migrations/2022_01_25_010223_create_payment_table.php @@ -13,18 +13,69 @@ class CreatePaymentTable extends Migration */ public function up() { + + Schema::create('invoice', function (Blueprint $table) { + $table->bigIncrements('id'); + $table->unsignedBigInteger('user_id')->unsigned(); + $table->unsignedBigInteger('lelong_id')->unsigned(); + $table->string('invoice_no')->nullable(); + $table->decimal('total_invoice', $precision = 11, $scale = 2); + $table->string('invoice_type'); // 1 = fee , 2 = bid + $table->string('status')->nullable(); //status => 1 = paid , 2 = pending + $table->string('opencash')->nullable()->default(0); + $table->timestamp('paid_at')->nullable(); + $table->timestamps(); + + $table->foreign('user_id') + ->references('id')->on('users') + ->onDelete('cascade'); + + $table->foreign('lelong_id') + ->references('id')->on('lelong') + ->onDelete('cascade'); + }); + + Schema::create('resit', function (Blueprint $table) { + $table->bigIncrements('id'); + $table->unsignedBigInteger('user_id')->unsigned(); + $table->unsignedBigInteger('lelong_id')->unsigned(); + $table->string('reference_no')->nullable(); + $table->unsignedBigInteger('invoice_id')->unsigned(); + $table->string('invoice_no')->nullable(); + $table->string('billplz_id'); + $table->decimal('total_payment', $precision = 11, $scale = 2); + $table->string('resit_type'); // 1 = fee , 2 = bid + $table->string('status')->nullable(); //status => 1 = paid , 2 = pending + $table->timestamp('paid_at')->nullable(); + $table->timestamps(); + + $table->foreign('invoice_id') + ->references('id')->on('invoice') + ->onDelete('cascade'); + + $table->foreign('user_id') + ->references('id')->on('users') + ->onDelete('cascade'); + + $table->foreign('lelong_id') + ->references('id')->on('lelong') + ->onDelete('cascade'); + }); + Schema::create('payment', function (Blueprint $table) { $table->bigIncrements('id'); $table->unsignedBigInteger('user_id')->unsigned(); $table->unsignedBigInteger('lelong_id')->unsigned(); + $table->unsignedBigInteger('lelongbid_id')->unsigned(); + $table->unsignedBigInteger('resit_id')->unsigned(); $table->string('kodcaw')->nullable(); + $table->integer('invoice_id')->nullable(); $table->string('norujukan')->nullable(); $table->string('back_acc_pembeli')->nullable(); $table->string('bank_acc_no_pembeli')->nullable(); $table->string('nama_bank_acc_caw')->nullable(); $table->string('bank_no_acc_caw')->nullable(); $table->integer('status_payment_opt')->nullable(); //1=kaunter,2=online,3=CDM - $table->integer('resit_id'); $table->integer('status'); //1 = fee RM10 , 2 = paybidifwin $table->string('remark'); $table->integer('1sen')->nullable(); @@ -45,6 +96,10 @@ class CreatePaymentTable extends Migration $table->integer('diminta_oleh')->nullable(); $table->timestamps(); + $table->foreign('resit_id') + ->references('id')->on('resit') + ->onDelete('cascade'); + $table->foreign('user_id') ->references('id')->on('users') ->onDelete('cascade'); @@ -52,6 +107,10 @@ class CreatePaymentTable extends Migration $table->foreign('lelong_id') ->references('id')->on('lelong') ->onDelete('cascade'); + + $table->foreign('lelongbid_id') + ->references('id')->on('lelongbid') + ->onDelete('cascade'); }); Schema::create('paydenokaunter', function (Blueprint $table) { @@ -90,50 +149,6 @@ class CreatePaymentTable extends Migration ->onDelete('cascade'); }); - Schema::create('resit', function (Blueprint $table) { - $table->bigIncrements('id'); - $table->unsignedBigInteger('user_id')->unsigned(); - $table->unsignedBigInteger('lelong_id')->unsigned(); - $table->string('reference_no')->nullable(); - $table->integer('invoice_id')->nullable(); - $table->string('invoice_no')->nullable(); - $table->string('billplz_id'); - $table->decimal('total_payment', $precision = 11, $scale = 2); - $table->string('resit_type'); // 1 = fee , 2 = bid - $table->string('status')->nullable(); //status => 1 = paid , 2 = pending - $table->timestamp('paid_at')->nullable(); - $table->timestamps(); - - $table->foreign('user_id') - ->references('id')->on('users') - ->onDelete('cascade'); - - $table->foreign('lelong_id') - ->references('id')->on('lelong') - ->onDelete('cascade'); - }); - - Schema::create('invoice', function (Blueprint $table) { - $table->bigIncrements('id'); - $table->unsignedBigInteger('user_id')->unsigned(); - $table->unsignedBigInteger('lelong_id')->unsigned(); - $table->string('invoice_no')->nullable(); - $table->decimal('total_invoice', $precision = 11, $scale = 2); - $table->string('invoice_type'); // 1 = fee , 2 = bid - $table->string('status')->nullable(); //status => 1 = paid , 2 = pending - $table->string('opencash')->nullable()->default(0); - $table->timestamp('paid_at')->nullable(); - $table->timestamps(); - - $table->foreign('user_id') - ->references('id')->on('users') - ->onDelete('cascade'); - - $table->foreign('lelong_id') - ->references('id')->on('lelong') - ->onDelete('cascade'); - }); - } /** diff --git a/resources/views/lelong/senarailelong.blade.php b/resources/views/lelong/senarailelong.blade.php index 5d9cb536..a1df1c3f 100644 --- a/resources/views/lelong/senarailelong.blade.php +++ b/resources/views/lelong/senarailelong.blade.php @@ -73,7 +73,6 @@ @elseif($data['laporan']['sts_lelong'] == 3) - EXPORT @endif @endhasrole @@ -97,6 +96,7 @@ {{-- --}} + Export @endif @endhasrole