diff --git a/app/Http/Controllers/KJPPController.php b/app/Http/Controllers/KJPPController.php index c005ff3..231a2ba 100644 --- a/app/Http/Controllers/KJPPController.php +++ b/app/Http/Controllers/KJPPController.php @@ -44,8 +44,13 @@ class KJPPController extends Controller // Combine KJPP number with branch code $fullKjppNumber = $kjppNumber; + $detailJoinEmailKantor = json_encode([]); + $detailJoinPimpinan = json_encode([]); + $detailJoinPicReviewer = json_encode([]); + $detailJoinPicAdmin = json_encode([]); + $detailJoinPicMarketing = json_encode([]); - return view('lpj::kjpp.create', compact('ijin_usaha', 'jenis_aset', 'provinces', 'fullKjppNumber')); + return view('lpj::kjpp.create', compact('ijin_usaha', 'jenis_aset', 'provinces', 'fullKjppNumber', 'detailJoinEmailKantor', 'detailJoinPimpinan', 'detailJoinPicReviewer', 'detailJoinPicAdmin', 'detailJoinPicMarketing')); } /** @@ -78,74 +83,56 @@ class KJPPController extends Controller $nomorHpPicMarketing = $request->input('detail_nomor_hp_pic_marketing.nomor_hp_pic_marketing', []); foreach ($emailKantor as $value) { - $detailEmailKantor[] = [ - 'email_kantor' => $value - ]; + $detailEmailKantor[] = $value; } // Encode to JSON and store $detailEmailKantorJson = json_encode($detailEmailKantor); // Process detail_nama_pimpinan foreach ($namaPimpinan as $value) { - $detailNamaPimpinan[] = [ - 'nama_pimpinan' => $value - ]; + $detailNamaPimpinan[] = $value; } $detailNamaPimpinanJson = json_encode($detailNamaPimpinan); // Process detail_nomor_pic_pimpinan foreach ($nomorHpPimpinan as $value) { - $detailNomorPicPimpinan[] = [ - 'nomor_hp_pimpinan' => $value - ]; + $detailNomorPicPimpinan[] = $value; } $detailNomorPicPimpinanJson = json_encode($detailNomorPicPimpinan); // Process detail_nama_pic_reviewer foreach ($namaPicReviewer as $value) { - $detailNamaPicReviewer[] = [ - 'nama_pic_reviewer' => $value - ]; + $detailNamaPicReviewer[] = $value; } $detailNamaPicReviewerJson = json_encode($detailNamaPicReviewer); // Process detail_nomor_hp_pic_reviewer foreach ($nomorHpPicReviewer as $value) { - $detailNomorHpPicReviewer[] = [ - 'nomor_hp_pic_reviewer' => $value - ]; + $detailNomorHpPicReviewer[] = $value; } $detailNomorHpPicReviewerJson = json_encode($detailNomorHpPicReviewer); // Process detail_nama_pic_admin foreach ($namaPicAdmin as $value) { - $detailNamaPicAdmin[] = [ - 'nama_pic_admin' => $value - ]; + $detailNamaPicAdmin[] = $value; } $detailNamaPicAdminJson = json_encode($detailNamaPicAdmin); // Process detail_nomor_hp_pic_admin foreach ($nomorHpPicAdmin as $value) { - $detailNomorHpPicAdmin[] = [ - 'nomor_hp_pic_admin' => $value - ]; + $detailNomorHpPicAdmin[] = $value; } $detailNomorHpPicAdminJson = json_encode($detailNomorHpPicAdmin); // Process detail_nama_pic_marketing foreach ($namaPicMarketing as $value) { - $detailNamaPicMarketing[] = [ - 'nama_pic_marketing' => $value - ]; + $detailNamaPicMarketing[] = $value; } $detailNamaPicMarketingJson = json_encode($detailNamaPicMarketing); // Process detail_nomor_hp_pic_marketing foreach ($nomorHpPicMarketing as $value) { - $detailNomorHpPicMarketing[] = [ - 'nomor_hp_pic_marketing' => $value - ]; + $detailNomorHpPicMarketing[] = $value; } $detailNomorHpPicMarketingJson = json_encode($detailNomorHpPicMarketing); @@ -217,15 +204,18 @@ class KJPPController extends Controller $detailNamaPicMarketing = json_decode($kjpp->detail_nama_pic_marketing); $detailNomorHpPicMarketing = json_decode($kjpp->detail_nomor_hp_pic_marketing); - $detailJoinPimpinan = []; - if ($detailNamaPimpinan) { - $detailJoinPimpinan = json_encode(array_map(function ($nama, $nomor) { - return [ - 'nama_pimpinan' => $nama, - 'nomor_hp_pimpinan' => $nomor - ]; - }, $detailNamaPimpinan, $detailNomorHpPimpinan)); - } + $detailJoinEmailKantor = json_encode(array_map(function ($email) { + return [ + 'email_kantor' => $email + ]; + }, $detailEmailKantor)); + + $detailJoinPimpinan = json_encode(array_map(function ($nama, $nomor) { + return [ + 'nama_pimpinan' => $nama, + 'nomor_hp_pimpinan' => $nomor + ]; + }, $detailNamaPimpinan, $detailNomorHpPimpinan)); $detailJoinPicReviewer = json_encode(array_map(function ($nama, $nomor) { @@ -249,7 +239,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', 'detailJoinPimpinan')); + return view('lpj::kjpp.show', compact('jenis_jaminan', 'ijin_usahas', 'ijin_usaha', 'kjpp', 'provinces', 'cities', 'districts', 'villages', 'detailJoinEmailKantor', 'detailJoinPicReviewer', 'detailJoinPicAdmin', 'detailJoinPicMarketing', 'detailJoinPimpinan')); } /** @@ -274,19 +264,19 @@ class KJPPController extends Controller $detailNamaPicMarketing = json_decode($kjpp->detail_nama_pic_marketing); $detailNomorHpPicMarketing = json_decode($kjpp->detail_nomor_hp_pic_marketing); - //dd($detailNamaPimpinan); + $detailJoinEmailKantor = json_encode(array_map(function ($email) { + return [ + 'email_kantor' => $email + ]; + }, $detailEmailKantor)); - $detailJoinPimpinan = []; - if ($detailNamaPimpinan) { - $detailJoinPimpinan = json_encode(array_map(function ($nama, $nomor) { - return [ - 'nama_pimpinan' => $nama, - 'nomor_hp_pimpinan' => $nomor - ]; - }, $detailNamaPimpinan, $detailNomorHpPimpinan)); - } + $detailJoinPimpinan = json_encode(array_map(function ($nama, $nomor) { + return [ + 'nama_pimpinan' => $nama, + 'nomor_hp_pimpinan' => $nomor + ]; + }, $detailNamaPimpinan, $detailNomorHpPimpinan)); - //dd($detailNamaPicReviewer ); $detailJoinPicReviewer = json_encode(array_map(function ($nama, $nomor) { return [ @@ -309,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', 'detailJoinPimpinan')); + return view('lpj::kjpp.create', compact('kjpp', 'ijin_usaha', 'jenis_aset', 'provinces', 'cities', 'districts', 'villages', 'detailJoinPicReviewer', 'detailJoinPicAdmin', 'detailJoinPicMarketing', 'detailJoinEmailKantor', 'detailJoinPimpinan')); } /** @@ -343,74 +333,56 @@ class KJPPController extends Controller $nomorHpPicMarketing = $request->input('detail_nomor_hp_pic_marketing.nomor_hp_pic_marketing', []); foreach ($emailKantor as $value) { - $detailEmailKantor[] = [ - 'email_kantor' => $value - ]; + $detailEmailKantor[] = $value; } // Encode to JSON and store $detailEmailKantorJson = json_encode($detailEmailKantor); // Process detail_nama_pimpinan foreach ($namaPimpinan as $value) { - $detailNamaPimpinan[] = [ - 'nama_pimpinan' => $value - ]; + $detailNamaPimpinan[] = $value; } $detailNamaPimpinanJson = json_encode($detailNamaPimpinan); // Process detail_nomor_hp_pimpinan foreach ($nomorHpPimpinan as $value) { - $detailNomorHpPimpinan[] = [ - 'nomor_hp_pimpinan' => $value - ]; + $detailNomorHpPimpinan[] = $value; } $detailNomorHpPimpinanJson = json_encode($detailNomorHpPimpinan); // Process detail_nama_pic_reviewer foreach ($namaPicReviewer as $value) { - $detailNamaPicReviewer[] = [ - 'nama_pic_reviewer' => $value - ]; + $detailNamaPicReviewer[] = $value; } $detailNamaPicReviewerJson = json_encode($detailNamaPicReviewer); // Process detail_nomor_hp_pic_reviewer foreach ($nomorHpPicReviewer as $value) { - $detailNomorHpPicReviewer[] = [ - 'nomor_hp_pic_reviewer' => $value - ]; + $detailNomorHpPicReviewer[] = $value; } $detailNomorHpPicReviewerJson = json_encode($detailNomorHpPicReviewer); // Process detail_nama_pic_admin foreach ($namaPicAdmin as $value) { - $detailNamaPicAdmin[] = [ - 'nama_pic_admin' => $value - ]; + $detailNamaPicAdmin[] = $value; } $detailNamaPicAdminJson = json_encode($detailNamaPicAdmin); // Process detail_nomor_hp_pic_admin foreach ($nomorHpPicAdmin as $value) { - $detailNomorHpPicAdmin[] = [ - 'nomor_hp_pic_admin' => $value - ]; + $detailNomorHpPicAdmin[] = $value; } $detailNomorHpPicAdminJson = json_encode($detailNomorHpPicAdmin); // Process detail_nama_pic_marketing foreach ($namaPicMarketing as $value) { - $detailNamaPicMarketing[] = [ - 'nama_pic_marketing' => $value - ]; + $detailNamaPicMarketing[] = $value; } $detailNamaPicMarketingJson = json_encode($detailNamaPicMarketing); // Process detail_nomor_hp_pic_marketing foreach ($nomorHpPicMarketing as $value) { - $detailNomorHpPicMarketing[] = [ - 'nomor_hp_pic_marketing' => $value - ]; + $detailNomorHpPicMarketing[] = $value; } $detailNomorHpPicMarketingJson = json_encode($detailNomorHpPicMarketing); @@ -449,7 +421,6 @@ class KJPPController extends Controller } else { $validated['jenis_aset_id'] = json_encode($validated['jenis_aset_id']); } - // Perbarui data di database KJPP::where('id', $id)->update($validated); diff --git a/app/Http/Requests/KJPPRequest.php b/app/Http/Requests/KJPPRequest.php index 4ff5821..28f1e7e 100644 --- a/app/Http/Requests/KJPPRequest.php +++ b/app/Http/Requests/KJPPRequest.php @@ -24,22 +24,31 @@ class KJPPRequest extends FormRequest 'nomor_telepon_kantor' => 'nullable|numeric|digits_between:8,15', 'email_kantor' => 'required|email', 'detail_email_kantor' => 'nullable', + 'detail_email_kantor.email_kantor.*' => 'email', 'nama_pimpinan' => 'required|string|not_regex:/^\d+$/|max:255', 'detail_nama_pimpinan' => 'nullable', + 'detail_nama_pimpinan.nama_pimpinan.*' => 'string|not_regex:/^\d+$/|max:255', 'nomor_hp_pimpinan' => 'required|numeric|digits_between:10,15', - 'detail_nomor_pic_pimpinan' => 'nullable', + 'detail_nomor_hp_pimpinan' => 'nullable', + 'detail_nomor_hp_pimpinan.nomor_hp_pimpinan.*' => 'numeric|digits_between:10,15', 'nama_pic_reviewer' => 'nullable|string|not_regex:/^\d+$/|max:255', 'detail_nama_pic_reviewer' => 'nullable', + 'detail_nama_pic_reviewer.nama_pic_reviewer.*' => 'string|not_regex:/^\d+$/|max:255', 'nomor_hp_pic_reviewer' => 'nullable|numeric|digits_between:10,15', 'detail_nomor_hp_pic_reviewer' => 'nullable', + 'detail_nomor_hp_pic_reviewer.nomor_hp_pic_reviewer.*' => 'numeric|digits_between:10,15', 'nama_pic_admin' => 'nullable|string|not_regex:/^\d+$/|max:255', 'detail_nama_pic_admin' => 'nullable', + 'detail_nama_pic_admin.nama_pic_admin.*' => 'string|not_regex:/^\d+$/|max:255', 'nomor_hp_pic_admin' => 'nullable|numeric|digits_between:10,15', 'detail_nomor_hp_pic_admin' => 'nullable', + 'detail_nomor_hp_pic_admin.nomor_hp_pic_admin.*' => 'numeric|digits_between:10,15', 'nama_pic_marketing' => 'nullable|string|not_regex:/^\d+$/|max:255', 'detail_nama_pic_marketing' => 'nullable', + 'detail_nama_pic_marketing.nama_pic_marketing.*' => 'string|not_regex:/^\d+$/|max:255', 'nomor_hp_pic_marketing' => 'nullable|numeric|digits_between:10,15', 'detail_nomor_hp_pic_marketing' => 'nullable', + 'detail_nomor_hp_pic_marketing.nomor_hp_pic_marketing.*' => 'numeric|digits_between:10,15', 'ijin_usaha_id' => 'required|array', 'ijin_usaha_id.*' => 'exists:ijin_usaha,code', 'jenis_aset_id' => 'nullable|array', @@ -83,20 +92,33 @@ class KJPPRequest extends FormRequest 'nomor_telepon_kantor.digits_between' => 'Nomor Telepon Kantor minimum 8 digit dan maksimum 15 digit!', 'email_kantor.required' => 'Email Kantor Wajib diisi!', 'email_kantor.email' => 'Email Kantor tidak valid!', + 'detail_email_kantor.email_kantor.*.email' => 'Email Kantor tidak valid!', 'nama_pimpinan.required' => 'Nama Pimpinan Wajib diisi!', 'nama_pimpinan.not_regex' => 'Nama Pimpinan harus berupa huruf!', + 'detail_nama_pimpinan.nama_pimpinan.*.not_regex' => 'Nama Pimpinan harus berupa huruf!', 'nomor_hp_pimpinan.required' => 'Nomor HP Pimpinan Wajib diisi!', 'nomor_hp_pimpinan.numeric' => 'Nomor HP Pimpinan harus berupa angka!', 'nomor_hp_pimpinan.digits_between' => 'Nomor HP Pimpinan minimum 10 digit dan maksimum 15 digit!', + 'detail_nomor_hp_pimpinan.nomor_hp_pimpinan.*.numeric' => 'Nomor HP Pimpinan harus berupa angka!', + 'detail_nomor_hp_pimpinan.nomor_hp_pimpinan.*.digits_between' => 'Nomor HP Pimpinan minimum 10 digit dan maksimum 15 digit!', 'nama_pic_reviewer.not_regex' => 'Nama PIC Reviewer harus berupa huruf!', + 'detail_nama_pic_reviewer.nama_pic_reviewer.*.not_regex' => 'Nama PIC Reviewer harus berupa huruf!', 'nomor_hp_pic_reviewer.numeric' => 'Nomor HP PIC Reviewer harus berupa angka!', 'nomor_hp_pic_reviewer.digits_between' => 'Nomor HP PIC Reviewer minimum 10 digit dan maksimum 15 digit!', + 'detail_nomor_hp_pic_reviewer.nomor_hp_pic_reviewer.*.numeric' => 'Nomor HP PIC Reviewer harus berupa angka!', + 'detail_nomor_hp_pic_reviewer.nomor_hp_pic_reviewer.*.digits_between' => 'Nomor HP PIC Reviewer minimum 10 digit dan maksimum 15 digit!', 'nama_pic_admin.not_regex' => 'Nama PIC Admin harus berupa huruf!', + 'detail_nama_pic_admin.nama_pic_admin.*.not_regex' => 'Nama PIC Admin harus berupa huruf!', 'nomor_hp_pic_admin.numeric' => 'Nomor HP PIC Admin harus berupa angka!', 'nomor_hp_pic_admin.digits_between' => 'Nomor HP PIC Admin minimum 10 digit dan maksimum 15 digit!', + 'detail_nomor_hp_pic_admin.nomor_hp_pic_admin.*.numeric' => 'Nomor HP PIC Admin harus berupa angka!', + 'detail_nomor_hp_pic_admin.nomor_hp_pic_admin.*.digits_between' => 'Nomor HP PIC Admin minimum 10 digit dan maksimum 15 digit!', 'nama_pic_marketing.not_regex' => 'Nama PIC Marketing harus berupa huruf!', + 'detail_nama_pic_marketing.nama_pic_marketing.*.not_regex' => 'Nama PIC Marketing harus berupa huruf!', 'nomor_hp_pic_marketing.numeric' => 'Nomor HP PIC Marketing harus berupa angka!', 'nomor_hp_pic_marketing.digits_between' => 'Nomor HP PIC Marketing minimum 10 digit dan maksimum 15 digit!', + 'detail_nomor_hp_pic_marketing.nomor_hp_pic_marketing.*.numeric' => 'Nomor HP PIC Marketing harus berupa angka!', + 'detail_nomor_hp_pic_marketing.nomor_hp_pic_marketing.*.digits_between' => 'Nomor HP PIC Marketing minimum 10 digit dan maksimum 15 digit!', 'ijin_usaha_id.required' => 'Ijin Usaha Wajib diisi!', 'attachment.mimes' => 'Attachment harus berformat pdf!', 'attachment.max' => 'Attachment berukuran maksimum 1 MB!', diff --git a/resources/views/kjpp/create.blade.php b/resources/views/kjpp/create.blade.php index 1bd1ff7..502e400 100644 --- a/resources/views/kjpp/create.blade.php +++ b/resources/views/kjpp/create.blade.php @@ -229,20 +229,32 @@ {{ $message }} @enderror
{{ $kjpp->email_kantor }}
- @if (isset($kjpp->detail_email_kantor)) - @foreach (json_decode($kjpp->detail_email_kantor) as $detail_email_kantor) + @if (!empty($detailJoinEmailKantor)) + @foreach (json_decode($detailJoinEmailKantor) as $detail_email_kantor)- {{ $detail_email_kantor }} + {{ $detail_email_kantor->email_kantor }}
@endforeach @endif @@ -239,9 +239,9 @@ @endforeach