From 6dd55f9532f0bea480b1e9d3a8c52adb17374c66 Mon Sep 17 00:00:00 2001 From: Daeng Deni Mardaeni Date: Mon, 4 Nov 2024 16:00:29 +0700 Subject: [PATCH] Add 'details' column to 'detail_dokumen_jaminan' table This migration adds a nullable 'details' column to the 'detail_dokumen_jaminan' table. The column is used to store custom field data in JSON format. Various parts of the application, including the model, controller, and view, have been updated to handle this new column. --- .../Controllers/DokumenJaminanController.php | 12 ++-- app/Models/DetailDokumenJaminan.php | 2 +- ...27_update_detail_dokumen_jaminan_table.php | 28 +++++++++ .../debitur/components/dokumen.blade.php | 59 +++++++++++++++---- 4 files changed, 83 insertions(+), 18 deletions(-) create mode 100644 database/migrations/2024_11_04_083227_update_detail_dokumen_jaminan_table.php diff --git a/app/Http/Controllers/DokumenJaminanController.php b/app/Http/Controllers/DokumenJaminanController.php index 83b75e0..dc4ac6e 100644 --- a/app/Http/Controllers/DokumenJaminanController.php +++ b/app/Http/Controllers/DokumenJaminanController.php @@ -88,6 +88,7 @@ 'dokumen_jaminan' => 'jaminan/' . $debitur->id . '/' . $document->id . '/' . $file_name, 'name' => $request->name[$key], 'keterangan' => $request->keterangan[$key], + 'details' => isset($request->custom_field[$key]) ? json_encode($request->custom_field[$key]) : '', ]; DetailDokumenJaminan::create($detail); } catch (Exception $e) { @@ -181,16 +182,19 @@ //dd($pemilik_jaminan); - try{ + try { $pemilikJaminan = PemilikJaminan::updateOrCreate([ 'debiture_id' => $id, 'name' => request()->get('pemilik_name'), ], $pemilik_jaminan); - } catch (Exception $e){ - return redirect()->route('debitur.jaminan.index', $id)->with('error', 'Gagal update pemilik jaminan: '. $e->getMessage()); + } catch (Exception $e) { + return redirect()->route('debitur.jaminan.index', $id)->with( + 'error', + 'Gagal update pemilik jaminan: ' . $e->getMessage(), + ); } - $validate['pemilik_jaminan_id']=$pemilikJaminan->id; + $validate['pemilik_jaminan_id'] = $pemilikJaminan->id; } diff --git a/app/Models/DetailDokumenJaminan.php b/app/Models/DetailDokumenJaminan.php index e164ea5..487cf75 100644 --- a/app/Models/DetailDokumenJaminan.php +++ b/app/Models/DetailDokumenJaminan.php @@ -17,7 +17,7 @@ 'name', 'dokumen_jaminan', 'keterangan', - + 'details', 'status', 'authorized_at', 'authorized_status', diff --git a/database/migrations/2024_11_04_083227_update_detail_dokumen_jaminan_table.php b/database/migrations/2024_11_04_083227_update_detail_dokumen_jaminan_table.php new file mode 100644 index 0000000..ad58fbf --- /dev/null +++ b/database/migrations/2024_11_04_083227_update_detail_dokumen_jaminan_table.php @@ -0,0 +1,28 @@ +string('details')->nullable()->after('dokumen_jaminan_id'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('detail_dokumen_jaminan', function (Blueprint $table) { + $table->dropColumn('details'); + }); + } +}; diff --git a/resources/views/debitur/components/dokumen.blade.php b/resources/views/debitur/components/dokumen.blade.php index e15a2b8..b3038ed 100644 --- a/resources/views/debitur/components/dokumen.blade.php +++ b/resources/views/debitur/components/dokumen.blade.php @@ -165,6 +165,18 @@ + @if($detail->details) + @php $custom_field = json_decode($detail->details,true) @endphp +
+ +
+ +
+
+ @endif +