DB::table('villages')->orderBy('village_name')->pluck('village_name', 'village_code'), 'district_name' => DB::table('districts')->orderBy('district_name')->pluck('district_name', 'district_code'), 'business_type_id' => DB::table('business_type')->orderBy('business_type')->pluck('business_type', 'id'), 'business_scale_id' => DB::table('business_scale')->orderBy('business_scale')->pluck('business_scale', 'id'), ]; $fields = $this->getFields(); $fieldTypes = $this->getFieldTypes(); $apiUrl = url('/api/tourisms'); return view('data.tourisms.form', compact('title', 'subtitle', 'fields', 'fieldTypes', 'apiUrl', 'dropdownOptions')); } /** * show the form for editing the specified resource. */ public function edit($id) { $title = 'Pariwisata'; $subtitle = 'Create Data'; $modelInstance = Tourism::find($id); // Pastikan model ditemukan if (!$modelInstance) { return redirect()->route('tourisms.index') ->with('error', 'Pariwisata tidak ditemukan'); } // Mengambil dan memetakan village_name dan district_name $village = DB::table('villages')->where('village_code', $modelInstance->village_code)->first(); $modelInstance->village_name = $village ? $village->village_name : null; $district = DB::table('districts')->where('district_code', $modelInstance->district_code)->first(); $modelInstance->district_name = $district ? $district->district_name : null; $business_type = DB::table('business_type')->where('id', $modelInstance->business_type_id)->first(); $modelInstance->business_scale_id = $business_type ? $business_type->id : null; $dropdownOptions = [ 'village_name' => DB::table('villages')->orderBy('village_name')->pluck('village_name', 'village_code'), 'district_name' => DB::table('districts')->orderBy('district_name')->pluck('district_name', 'district_code'), 'business_type_id' => DB::table('business_type')->orderBy('business_type')->pluck('business_type', 'id'), ]; $fields = $this->getFields(); $fieldTypes = $this->getFieldTypes(); $apiUrl = url('/api/tourisms'); return view('data.tourisms.form', compact('title', 'subtitle', 'modelInstance', 'fields', 'fieldTypes', 'apiUrl', 'dropdownOptions')); } private function getFields() { return [ "business_name" => "Nama Usaha", "business_form" => "Bentuk Usaha", "project_name" => "Nama Project", "business_address" => "Alamat Usaha", "district_name" => "Kecamatan", "village_name" => "Desa", "land_area" => "Luas Tanah", "investment_amount" => "Jumlah Investasi", "number_of_employee" => "TKI", "business_type_id" => "Jenis Usaha", "project_id" => "Priject ID", "nib" => "NIB", "jenis_proyek" => "Jenis Proyek", "status_penanaman_modal" => "Status Penanaman Modal", "uraian_resiko_proyek" => "Uraian Resiko Proyek", "business_scale_id" => "Skala Bisnis/Usaha", "terbit_oss" => "Terbit OSS", ]; } private function getFieldTypes() { return [ "business_name" => "text", "business_form" => "text", "project_name" => "text", "business_address" => "textarea", "district_name" => "combobox", "village_name" => "combobox", "land_area" => "text", "investment_amount" => "text", "number_of_employee" => "text", "business_type_id" => "select", "project_id" => "text", "nib" => "text", "jenis_proyek" => "text", "status_penanaman_modal" => "text", "uraian_resiko_proyek" => "text", "business_scale_id" => "select", "terbit_oss" => "date" ]; } }