From e6d05cc4aa9d62bebebefeba2db590a8f986eb4c Mon Sep 17 00:00:00 2001 From: Daeng Deni Mardaeni Date: Mon, 5 May 2025 11:37:51 +0700 Subject: [PATCH] feat(noc): tambahkan fitur Noc untuk pengelolaan data penyelesaian - Menambahkan model baru untuk tabel `noc` beserta relasinya pada `Permohonan` dan `PersetujuanPenawaran`. - Menambahkan migrasi untuk membuat tabel `noc` di database. - Memodifikasi logika dan format data pada `NocController` untuk mendukung data terkait `noc`. - Mendefinisikan relasi baru di model `Permohonan` dan `PersetujuanPenawaran` untuk mendukung fitur `noc`. Signed-off-by: Daeng Deni Mardaeni --- app/Http/Controllers/NocController.php | 13 ++-- app/Models/Noc.php | 61 +++++++++++++++++++ app/Models/Permohonan.php | 6 ++ app/Models/PersetujuanPenawaran.php | 7 ++- .../2025_05_04_124217_create_nocs_table.php | 51 ++++++++++++++++ 5 files changed, 132 insertions(+), 6 deletions(-) create mode 100644 app/Models/Noc.php create mode 100644 database/migrations/2025_05_04_124217_create_nocs_table.php diff --git a/app/Http/Controllers/NocController.php b/app/Http/Controllers/NocController.php index 87a50b8..3186d82 100644 --- a/app/Http/Controllers/NocController.php +++ b/app/Http/Controllers/NocController.php @@ -109,7 +109,7 @@ /** * Display the specified resource. */ - public function show($id) { } + public function show($id) {} /** * Show the form for editing the specified resource. @@ -181,10 +181,13 @@ 'nomor_registrasi' => $persetujuanPenawaran->permohonan->nomor_registrasi ?? $persetujuanPenawaran->penawaran->nomor_registrasi, 'nama_debitur' => $persetujuanPenawaran->permohonan->debiture->name ?? $persetujuanPenawaran->penawaran->permohonan->debiture->name, 'cabang' => $persetujuanPenawaran->permohonan->branch->name ?? $persetujuanPenawaran->penawaran->permohonan->branch->name, - 'tanggal_setor' => formatTanggalIndonesia($persetujuanPenawaran->created_at, true), - 'nominal_bayar' => format_currency($persetujuanPenawaran->nominal_bayar ?? 0), - 'bukti_ksl' => $persetujuanPenawaran->bukti_ksl ?? null, - 'tanggal_penyelesaian' => formatTanggalIndonesia($persetujuanPenawaran->updated_at, true), + 'tanggal_setor' => dateFormat($persetujuanPenawaran->moc->created_at ?? $persetujuanPenawaran->created_at, true), + 'nominal_bayar' => currencyFormat($persetujuanPenawaran->noc->nominal_bayar ?? $persetujuanPenawaran->nominal_bayar ?? 0), + 'bukti_ksl' => $persetujuanPenawaran->noc->bukti_ksl ?? $persetujuanPenawaran->bukti_ksl ?? null, + 'memo_penyelesaian' => $persetujuanPenawaran->noc->memo_penyelesaian ?? $persetujuanPenawaran->memo_penyelesaian ?? null, + 'nominal_penyelesaian' => currencyFormat($persetujuanPenawaran->noc->nominal_penyelesaian ?? $persetujuanPenawaran->nominal_penyelesaian ?? 0), + 'bukti_penyelesaian' => $persetujuanPenawaran->noc->bukti_penyelesaian ?? $persetujuanPenawaran->bukti_penyelesaian ?? null, + 'tanggal_penyelesaian' => dateFormat($persetujuanPenawaran->noc->tanggal_penyelesaian ?? $persetujuanPenawaran->updated_at, true), ]; }); diff --git a/app/Models/Noc.php b/app/Models/Noc.php new file mode 100644 index 0000000..a9104fd --- /dev/null +++ b/app/Models/Noc.php @@ -0,0 +1,61 @@ + 'decimal:2', + 'status_bayar' => 'boolean', + 'tanggal_pembayaran' => 'date', + 'nominal_penyelesaian' => 'decimal:2', + 'status_penyelesaiaan' => 'boolean', + 'tanggal_penyelesaian' => 'date', + 'status' => 'boolean', + 'authorized_status' => 'boolean', + 'authorized_at' => 'datetime', + ]; + + // Relationship with Permohonan + public function permohonan() + { + return $this->belongsTo(Permohonan::class, 'permohonan_id'); + } + + // Relationship with PersetujuanPenawaran + public function persetujuanPenawaran() + { + return $this->belongsTo(PersetujuanPenawaran::class, 'persetujuan_penawaran_id'); + } + + // Relationship with User (for authorized_by) + public function authorizedBy() + { + return $this->belongsTo(User::class, 'authorized_by'); + } +} diff --git a/app/Models/Permohonan.php b/app/Models/Permohonan.php index 5644430..4490721 100644 --- a/app/Models/Permohonan.php +++ b/app/Models/Permohonan.php @@ -259,4 +259,10 @@ return $this->belongsTo(Inspeksi::class, 'permohonan_id'); } + // Add this relationship + public function noc() + { + return $this->hasOne(Noc::class, 'permohonan_id'); + } + } diff --git a/app/Models/PersetujuanPenawaran.php b/app/Models/PersetujuanPenawaran.php index 014a5a3..0bb8158 100644 --- a/app/Models/PersetujuanPenawaran.php +++ b/app/Models/PersetujuanPenawaran.php @@ -25,7 +25,6 @@ 'authorized_status', 'authorized_at', 'authorized_by', - 'status', 'catatan', ]; @@ -58,4 +57,10 @@ { return $this->belongsTo(User::class, 'authorized_by'); } + + // Relationship with Noc + public function noc() + { + return $this->hasOne(Noc::class, 'persetujuan_penawaran_id'); + } } diff --git a/database/migrations/2025_05_04_124217_create_nocs_table.php b/database/migrations/2025_05_04_124217_create_nocs_table.php new file mode 100644 index 0000000..4630297 --- /dev/null +++ b/database/migrations/2025_05_04_124217_create_nocs_table.php @@ -0,0 +1,51 @@ +id(); + $table->unsignedBigInteger('permohonan_id'); + $table->unsignedBigInteger('persetujuan_penawaran_id'); + $table->string('bukti_bayar')->nullable(); + $table->decimal('nominal_bayar', 15, 2)->nullable(); + $table->boolean('status_bayar')->default(false); + $table->date('tanggal_pembayaran')->nullable(); + $table->decimal('nominal_penyelesaian', 15, 2)->nullable(); + $table->boolean('status_penyelesaiaan')->default(false); + $table->date('tanggal_penyelesaian')->nullable(); + $table->string('bukti_penyelesaian')->nullable(); + $table->string('bukti_ksl')->nullable(); + $table->text('memo_penyelesaian')->nullable(); + $table->boolean('status')->default(true); + $table->char('authorized_status', 1)->nullable(); + $table->timestamp('authorized_at')->nullable(); + $table->unsignedBigInteger('authorized_by')->nullable(); + $table->unsignedBigInteger('created_by')->nullable(); + $table->unsignedBigInteger('updated_by')->nullable(); + $table->unsignedBigInteger('deleted_by')->nullable(); + $table->timestamps(); + $table->softDeletes(); + + $table->foreign('permohonan_id')->references('id')->on('permohonan'); + $table->foreign('persetujuan_penawaran_id')->references('id')->on('persetujuan_penawaran'); + }); + } + + /** + * Reverse the migrations. + */ + public function down() + : void + { + Schema::dropIfExists('noc'); + } + };