diff --git a/app/Http/Controllers/KJPPController.php b/app/Http/Controllers/KJPPController.php index e043735..875b256 100644 --- a/app/Http/Controllers/KJPPController.php +++ b/app/Http/Controllers/KJPPController.php @@ -55,8 +55,11 @@ class KJPPController extends Controller { $validated = $request->validated(); + if ($validated) { $detailEmailKantor = []; + $detailNamaPimpinan = []; + $detailNomorPicPimpinan = []; $detailNamaPicReviewer = []; $detailNomorHpPicReviewer = []; $detailNamaPicAdmin = []; @@ -65,6 +68,8 @@ class KJPPController extends Controller $detailNomorHpPicMarketing = []; $emailKantor = $request->input('detail_email_kantor.email_kantor', []); + $namaPimpinan = $request->input('detail_nama_pimpinan.nama_pimpinan', []); + $nomorHpPimpinan = $request->input('detail_nomor_hp_pimpinan.nomor_hp_pimpinan', []); $namaPicReviewer = $request->input('detail_nama_pic_reviewer.nama_pic_reviewer', []); $nomorHpPicReviewer = $request->input('detail_nomor_hp_pic_reviewer.nomor_hp_pic_reviewer', []); $namaPicAdmin = $request->input('detail_nama_pic_admin.nama_pic_admin', []); @@ -80,6 +85,22 @@ class KJPPController extends Controller // Encode to JSON and store $detailEmailKantorJson = json_encode($detailEmailKantor); + // Process detail_nama_pimpinan + foreach ($namaPimpinan as $value) { + $detailNamaPimpinan[] = [ + 'nama_pimpinan' => $value + ]; + } + $detailNamaPimpinanJson = json_encode($detailNamaPimpinan); + + // Process detail_nomor_pic_pimpinan + foreach ($nomorHpPimpinan as $value) { + $detailNomorPicPimpinan[] = [ + 'nomor_hp_pimpinan' => $value + ]; + } + $detailNomorPicPimpinanJson = json_encode($detailNomorPicPimpinan); + // Process detail_nama_pic_reviewer foreach ($namaPicReviewer as $value) { $detailNamaPicReviewer[] = [ @@ -141,6 +162,8 @@ class KJPPController extends Controller } $validated['detail_email_kantor'] = $detailEmailKantorJson; + $validated['detail_nama_pimpinan'] = $detailNamaPimpinanJson; + $validated['detail_nomor_hp_pimpinan'] = $detailNomorPicPimpinanJson; $validated['detail_nama_pic_reviewer'] = $detailNamaPicReviewerJson; $validated['detail_nomor_hp_pic_reviewer'] = $detailNomorHpPicReviewerJson; $validated['detail_nama_pic_admin'] = $detailNamaPicAdminJson; @@ -181,6 +204,8 @@ class KJPPController extends Controller $districts = District::where('code', $kjpp->district_code)->get(); $villages = Village::where('code', $kjpp->village_code)->get(); $detailEmailKantor = json_decode($kjpp->detail_email_kantor); + $detailNamaPimpinan = json_decode($kjpp->detail_nama_pimpinan); + $detailNomorHpPimpinan = json_decode($kjpp->detail_nomor_hp_pimpinan); $detailNamaPicReviewer = json_decode($kjpp->detail_nama_pic_reviewer); $detailNomorHpPicReviewer = json_decode($kjpp->detail_nomor_hp_pic_reviewer); $detailNamaPicAdmin = json_decode($kjpp->detail_nama_pic_admin); @@ -188,6 +213,14 @@ class KJPPController extends Controller $detailNamaPicMarketing = json_decode($kjpp->detail_nama_pic_marketing); $detailNomorHpPicMarketing = json_decode($kjpp->detail_nomor_hp_pic_marketing); + $detailJoinPimpinan = json_encode(array_map(function ($nama, $nomor) { + return [ + 'nama_pimpinan' => $nama->nama_pimpinan, + 'nomor_hp_pimpinan' => $nomor->nomor_hp_pimpinan + ]; + }, $detailNamaPimpinan, $detailNomorHpPimpinan)); + + $detailJoinPicReviewer = json_encode(array_map(function ($nama, $nomor) { return [ 'nama_pic_reviewer' => $nama->nama_pic_reviewer, @@ -209,7 +242,7 @@ class KJPPController extends Controller ]; }, $detailNamaPicMarketing, $detailNomorHpPicMarketing)); - return view('lpj::kjpp.show', compact('jenis_jaminan', 'ijin_usahas', 'ijin_usaha', 'kjpp', 'provinces', 'cities', 'districts', 'villages', 'detailEmailKantor', 'detailJoinPicReviewer', 'detailJoinPicAdmin', 'detailJoinPicMarketing')); + return view('lpj::kjpp.show', compact('jenis_jaminan', 'ijin_usahas', 'ijin_usaha', 'kjpp', 'provinces', 'cities', 'districts', 'villages', 'detailEmailKantor', 'detailJoinPicReviewer', 'detailJoinPicAdmin', 'detailJoinPicMarketing', 'detailJoinPimpinan')); } /** @@ -225,6 +258,8 @@ class KJPPController extends Controller $districts = District::where('city_code', $kjpp->city_code)->get(); $villages = Village::where('district_code', $kjpp->district_code)->get(); $detailEmailKantor = json_decode($kjpp->detail_email_kantor); + $detailNamaPimpinan = json_decode($kjpp->detail_nama_pimpinan); + $detailNomorHpPimpinan = json_decode($kjpp->detail_nomor_hp_pimpinan); $detailNamaPicReviewer = json_decode($kjpp->detail_nama_pic_reviewer); $detailNomorHpPicReviewer = json_decode($kjpp->detail_nomor_hp_pic_reviewer); $detailNamaPicAdmin = json_decode($kjpp->detail_nama_pic_admin); @@ -232,6 +267,17 @@ class KJPPController extends Controller $detailNamaPicMarketing = json_decode($kjpp->detail_nama_pic_marketing); $detailNomorHpPicMarketing = json_decode($kjpp->detail_nomor_hp_pic_marketing); + // dd($detailNamaPimpinan); + + $detailJoinPimpinan = json_encode(array_map(function ($nama, $nomor) { + return [ + 'nama_pimpinan' => $nama->nama_pimpinan, + 'nomor_hp_pimpinan' => $nomor->nomor_hp_pimpinan + ]; + }, $detailNamaPimpinan, $detailNomorHpPimpinan)); + + // dd($detailJoinPimpinan); + $detailJoinPicReviewer = json_encode(array_map(function ($nama, $nomor) { return [ 'nama_pic_reviewer' => $nama->nama_pic_reviewer, @@ -253,7 +299,7 @@ class KJPPController extends Controller ]; }, $detailNamaPicMarketing, $detailNomorHpPicMarketing)); - return view('lpj::kjpp.create', compact('kjpp', 'ijin_usaha', 'jenis_aset', 'provinces', 'cities', 'districts', 'villages', 'detailJoinPicReviewer', 'detailJoinPicAdmin', 'detailJoinPicMarketing', 'detailEmailKantor')); + return view('lpj::kjpp.create', compact('kjpp', 'ijin_usaha', 'jenis_aset', 'provinces', 'cities', 'districts', 'villages', 'detailJoinPicReviewer', 'detailJoinPicAdmin', 'detailJoinPicMarketing', 'detailEmailKantor', 'detailJoinPimpinan')); } /** @@ -267,6 +313,8 @@ class KJPPController extends Controller if ($validated) { $detailEmailKantor = []; + $detailNamaPimpinan = []; + $detailNomorHpPimpinan = []; $detailNamaPicReviewer = []; $detailNomorHpPicReviewer = []; $detailNamaPicAdmin = []; @@ -275,6 +323,8 @@ class KJPPController extends Controller $detailNomorHpPicMarketing = []; $emailKantor = $request->input('detail_email_kantor.email_kantor', []); + $namaPimpinan = $request->input('detail_nama_pimpinan.nama_pimpinan', []); + $nomorHpPimpinan = $request->input('detail_nomor_hp_pimpinan.nomor_hp_pimpinan', []); $namaPicReviewer = $request->input('detail_nama_pic_reviewer.nama_pic_reviewer', []); $nomorHpPicReviewer = $request->input('detail_nomor_hp_pic_reviewer.nomor_hp_pic_reviewer', []); $namaPicAdmin = $request->input('detail_nama_pic_admin.nama_pic_admin', []); @@ -290,6 +340,22 @@ class KJPPController extends Controller // Encode to JSON and store $detailEmailKantorJson = json_encode($detailEmailKantor); + // Process detail_nama_pimpinan + foreach ($namaPimpinan as $value) { + $detailNamaPimpinan[] = [ + 'nama_pimpinan' => $value + ]; + } + $detailNamaPimpinanJson = json_encode($detailNamaPimpinan); + + // Process detail_nomor_hp_pimpinan + foreach ($nomorHpPimpinan as $value) { + $detailNomorHpPimpinan[] = [ + 'nomor_hp_pimpinan' => $value + ]; + } + $detailNomorHpPimpinanJson = json_encode($detailNomorHpPimpinan); + // Process detail_nama_pic_reviewer foreach ($namaPicReviewer as $value) { $detailNamaPicReviewer[] = [ @@ -359,6 +425,8 @@ class KJPPController extends Controller } $validated['detail_email_kantor'] = $detailEmailKantorJson; + $validated['detail_nama_pimpinan'] = $detailNamaPimpinanJson; + $validated['detail_nomor_hp_pimpinan'] = $detailNomorHpPimpinanJson; $validated['detail_nama_pic_reviewer'] = $detailNamaPicReviewerJson; $validated['detail_nomor_hp_pic_reviewer'] = $detailNomorHpPicReviewerJson; $validated['detail_nama_pic_admin'] = $detailNamaPicAdminJson; diff --git a/app/Http/Requests/KJPPRequest.php b/app/Http/Requests/KJPPRequest.php index 6a693a8..dedf16d 100644 --- a/app/Http/Requests/KJPPRequest.php +++ b/app/Http/Requests/KJPPRequest.php @@ -25,7 +25,9 @@ class KJPPRequest extends FormRequest 'email_kantor' => 'required|email', 'detail_email_kantor' => 'nullable', 'nama_pimpinan' => 'required|string|not_regex:/^\d+$/|max:255', + 'detail_nama_pimpinan' => 'nullable', 'nomor_hp_pimpinan' => 'required|numeric|digits_between:10,15', + 'detail_nomor_pic_pimpinan' => 'nullable', 'nama_pic_reviewer' => 'nullable|string|not_regex:/^\d+$/|max:255', 'detail_nama_pic_reviewer' => 'nullable', 'nomor_hp_pic_reviewer' => 'nullable|numeric|digits_between:10,15', diff --git a/database/migrations/2024_11_11_063934_update_kjpp_table.php b/database/migrations/2024_11_11_063934_update_kjpp_table.php new file mode 100644 index 0000000..6237a41 --- /dev/null +++ b/database/migrations/2024_11_11_063934_update_kjpp_table.php @@ -0,0 +1,30 @@ +string('detail_nama_pimpinan')->nullable()->after('nama_pimpinan'); + $table->string('detail_nomor_hp_pimpinan')->nullable()->after('nomor_hp_pimpinan'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('kjpp', function (Blueprint $table) { + $table->dropColumn('detail_nama_pimpinan'); + $table->dropColumn('detail_nomor_hp_pimpinan'); + }); + } +}; diff --git a/resources/views/kjpp/create.blade.php b/resources/views/kjpp/create.blade.php index 46fba2a..1bd1ff7 100644 --- a/resources/views/kjpp/create.blade.php +++ b/resources/views/kjpp/create.blade.php @@ -273,6 +273,50 @@ @enderror +
{{ $kjpp->nama_pimpinan }}
+ @if (isset($kjpp->detail_nama_pimpinan)) + @foreach (json_decode($detailJoinPimpinan) as $detail_nama_pimpinan) ++ {{ $detail_nama_pimpinan->nama_pimpinan }} +
+ @endforeach + @endif{{ $kjpp->nomor_hp_pimpinan }}
+ @if (isset($kjpp->detail_nomor_hp_pimpinan)) + @foreach (json_decode($detailJoinPimpinan) as $detail_nomor_hp_pimpinan) ++ {{ $detail_nomor_hp_pimpinan->nomor_hp_pimpinan }} +
+ @endforeach + @endif{{ $kjpp->nama_pic_reviewer }}
+{{ $kjpp->nama_pic_reviewer ?? '-' }}
@if (isset($kjpp->detail_nama_pic_reviewer)) - @foreach (json_decode($kjpp->detail_nama_pic_reviewer) as $detail_nama_pic_reviewer) + @foreach (json_decode($detailJoinPicReviewer) as $detail_nama_pic_reviewer){{ $detail_nama_pic_reviewer->nama_pic_reviewer }}
@@ -137,9 +151,10 @@ Nomor HP PIC Reviewer{{ $kjpp->nomor_hp_pic_reviewer }}
+{{ $kjpp->nomor_hp_pic_reviewer ?? '-' }} +
@if (isset($kjpp->detail_nomor_hp_pic_reviewer)) - @foreach (json_decode($kjpp->detail_nomor_hp_pic_reviewer) as $detail_nomor_hp_pic_reviewer) + @foreach (json_decode($detailJoinPicReviewer) as $detail_nomor_hp_pic_reviewer){{ $detail_nomor_hp_pic_reviewer->nomor_hp_pic_reviewer }}
@@ -152,9 +167,9 @@ Nama PIC Admin{{ $kjpp->nama_pic_admin }}
+{{ $kjpp->nama_pic_admin ?? '-' }}
@if (isset($kjpp->detail_nama_pic_admin)) - @foreach (json_decode($kjpp->detail_nama_pic_admin) as $detail_nama_pic_admin) + @foreach (json_decode($detailJoinPicAdmin) as $detail_nama_pic_admin){{ $detail_nama_pic_admin->nama_pic_admin }}
@@ -165,9 +180,9 @@ Nomor HP PIC Admin{{ $kjpp->nomor_hp_pic_admin }}
+{{ $kjpp->nomor_hp_pic_admin ?? '-' }}
@if (isset($kjpp->detail_nomor_hp_pic_admin)) - @foreach (json_decode($kjpp->detail_nomor_hp_pic_admin) as $detail_nomor_hp_pic_admin) + @foreach (json_decode($detailJoinPicAdmin) as $detail_nomor_hp_pic_admin){{ $detail_nomor_hp_pic_admin->nomor_hp_pic_admin }}
@@ -180,9 +195,9 @@ Nama PIC Marketing{{ $kjpp->nama_pic_marketing }}
+{{ $kjpp->nama_pic_marketing ?? '-' }}
@if (isset($kjpp->detail_nama_pic_marketing)) - @foreach (json_decode($kjpp->detail_nama_pic_marketing) as $detail_nama_pic_marketing) + @foreach (json_decode($detailJoinPicMarketing) as $detail_nama_pic_marketing){{ $detail_nama_pic_marketing->nama_pic_marketing }}
@@ -193,9 +208,10 @@ Nomor HP PIC Marketing{{ $kjpp->nomor_hp_pic_marketing }}
+{{ $kjpp->nomor_hp_pic_marketing ?? '-' }} +
@if (isset($kjpp->detail_nomor_hp_pic_marketing)) - @foreach (json_decode($kjpp->detail_nomor_hp_pic_marketing) as $detail_nomor_hp_pic_marketing) + @foreach (json_decode($detailJoinPicMarketing) as $detail_nomor_hp_pic_marketing){{ $detail_nomor_hp_pic_marketing->nomor_hp_pic_marketing }}