Merge branch 'bug-fix/tourisms' into feat/dashboard-kekurangan-potensi

This commit is contained in:
arifal
2025-02-19 06:17:16 +07:00
18 changed files with 331 additions and 139 deletions

View File

@@ -21,7 +21,6 @@ class TourismController extends Controller
*/
public function index(Request $request)
{
info($request);
$perPage = $request->input('per_page', 15);
$search = $request->input('search', '');
@@ -31,12 +30,9 @@ class TourismController extends Controller
$tourisms->getCollection()->transform(function ($tourisms) {
$village = DB::table('villages')->where('village_code', $tourisms->village_code)->first();
$tourisms->village_name = $village ? $village->village_name : null;
$district = DB::table('districts')->where('district_code', $tourisms->district_code)->first();
$tourisms->district_name = $district ? $district->district_name : null;
$business_type = DB::table('business_type')->where('id', $tourisms->business_type_id)->first();
$tourisms->business_type = $business_type ? $business_type->business_type : null;
$district = DB::table('districts')->where('district_code', $tourisms->district_code)->first();
$tourisms->district_name = $village ? $village->village_name : null;
return $tourisms;
});
@@ -46,7 +42,7 @@ class TourismController extends Controller
'total' => $tourisms->total(),
'per_page' => $tourisms->perPage(),
'current_page' => $tourisms->currentPage(),
'last_page' => $tourisms->lastPage(),
'last_page'=>$tourisms->lastPage(),
]
]);
}
@@ -62,11 +58,12 @@ class TourismController extends Controller
$data['district_code'] = $district_code;
$data['village_code'] = $village_code;
return Tourism::create($data);
}
/**
* Import advertisements from Excel or CSV
* Import advertisements from Excel
*/
public function importFromFile(Request $request)
{
@@ -77,21 +74,21 @@ class TourismController extends Controller
if ($validator->fails()) {
return response()->json([
'message' => 'File validation failed.',
'errors' => $validator->errors()
'message'=>'File validation failed.',
'errors'=>$validator->errors()
], 400);
}
try {
$file = $request->file('file');
Excel::import(new TourismImport, $file);
return response()->json([
'message' => 'File uploaded and imported successfully!'
'message'=>'File uploaded and imported successfully!'
], 200);
} catch (\Exception $e) {
return response()->json([
'message' => 'Error during file import.',
'error' => $e->getMessage()
'message'=>'Error during file import.',
'error'=>$e->getMessage()
], 500);
}
}
@@ -109,7 +106,17 @@ class TourismController extends Controller
*/
public function update(TourismRequest $request, Tourism $tourism): Tourism
{
$tourism->update($request->validated());
$data = $request->validated();
// Cari district_code berdasarkan district_name
$district_code = DB::table('districts')->where('district_name', $data['district_name'])->value('district_code');
// Cari village_code berdasarkan village_name
$village_code = DB::table('villages')->where('village_name', $data['village_name'])->where('district_code', $district_code)->value('village_code');
// Tambahkan village_code dan district_code ke data
$data['village_code'] = $village_code;
$data['district_code'] = $district_code;
$tourism->update($data);
return $tourism;
}

View File

@@ -69,9 +69,9 @@ class UmkmController extends Controller
// Cari kode berdasarkan nama
$district_code = DB::table('districts')->where('district_name', $data['district_name'])->value('district_code');
$village_code = DB::table('villages')->where('village_name', $data['village_name'])->where('district_code', $district_code)->value('village_code');
$business_scale_id = DB::table('business_scale')->where('id', $data['business_scale'])->value('id');
$permit_status_id = DB::table('permit_status')->where('id', $data['permit_status'])->value('id');
$business_form_id = DB::table('business_form')->where('id', $data['business_form'])->value('id');
$business_scale_id = DB::table('business_scale')->where('id', $data['business_scale_id'])->value('id');
$permit_status_id = DB::table('permit_status')->where('id', $data['permit_status_id'])->value('id');
$business_form_id = DB::table('business_form')->where('id', $data['business_form_id'])->value('id');
info($business_scale_id);

View File

@@ -36,9 +36,7 @@ class TourismController extends Controller
// Mengambil data untuk dropdown
$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'),
'business_scale_id' => DB::table('business_scale')->orderBy('business_scale')->pluck('business_scale', 'id'),
'district_name' => DB::table('districts')->orderBy('district_name')->pluck('district_name', 'district_code')
];
$fields = $this->getFields();
@@ -70,13 +68,9 @@ class TourismController extends Controller
$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'),
'district_name' => DB::table('districts')->orderBy('district_name')->pluck('district_name', 'district_code')
];
$fields = $this->getFields();
@@ -90,46 +84,62 @@ class TourismController extends Controller
private function getFields()
{
return [
"business_name" => "Nama Usaha",
"business_form" => "Bentuk Usaha",
"project_name" => "Nama Project",
"project_id" => "ID Proyek",
"project_type_id" => "Jenis Proyek",
"nib" => "NIB",
"business_name" => "Nama Perusahaan",
"oss_publication_date" => "Tanggal Terbit OSS",
"investment_status_description" => "Uraian Status Penanaman Modal",
"business_form" => "Uraian Jenis Perusahaan",
"project_risk" => "Risiko Proyek",
"project_name" => "Nama Proyek",
"business_scale" => "Uraian Skala Usaha",
"business_address" => "Alamat Usaha",
"district_name" => "Kecamatan",
"village_name" => "Desa",
"land_area" => "Luas Tanah",
"longitude" => "Longitude",
"latitude" => "Latitude",
"project_submission_date" => "Tanggal Pengajuan Project",
"kbli" => "KBLI",
"kbli_title" => "Judul KBLI",
"supervisory_sector" => "Sektor Pembina",
"user_name" => "Nama User",
"email" => "Email",
"contact" => "Kontak",
"land_area_in_m2" => "Luas Tanah (m2)",
"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",
"tki" => "TKI",
];
}
private function getFieldTypes()
{
return [
"project_id" => "text",
"project_type_id" => "text",
"nib" => "text",
"business_name" => "text",
"oss_publication_date" => "date",
"investment_status_description" => "text",
"business_form" => "text",
"project_risk" => "text",
"project_name" => "text",
"business_address" => "textarea",
"business_scale" => "text",
"business_address" => "text",
"district_name" => "combobox",
"village_name" => "combobox",
"land_area" => "text",
"longitude" => "text",
"latitude" => "text",
"project_submission_date" => "date",
"kbli" => "text",
"kbli_title" => "text",
"supervisory_sector" => "text",
"user_name" => "text",
"email" => "text",
"contact" => "text",
"land_area_in_m2" => "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"
"tki" => "text",
];
}
}

View File

@@ -3,7 +3,7 @@
namespace App\Http\Controllers\Report;
use App\Http\Controllers\Controller;
use App\Models\BusinessTypeCount;
use App\Models\TourismBasedKBLI;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
@@ -14,8 +14,8 @@ class ReportTourismController extends Controller
*/
public function index()
{
$businessTypeCounts = BusinessTypeCount::all();
info($businessTypeCounts);
return view('report.tourisms.index', compact('businessTypeCounts'));
$tourismBasedKBLI = TourismBasedKBLI::all();
info($tourismBasedKBLI);
return view('report.tourisms.index', compact('tourismBasedKBLI'));
}
}