diff --git a/app/Http/Controllers/Api/AdvertisementController.php b/app/Http/Controllers/Api/AdvertisementController.php index 85f5557..df8ff48 100644 --- a/app/Http/Controllers/Api/AdvertisementController.php +++ b/app/Http/Controllers/Api/AdvertisementController.php @@ -199,7 +199,7 @@ class AdvertisementController extends Controller public function downloadExcelAdvertisement() { - $filePath = storage_path('app/public/templates/template_reklame.xlsx'); + $filePath = public_path('templates/template_reklame.xlsx'); // Cek apakah file ada if (!file_exists($filePath)) { diff --git a/app/Http/Controllers/Api/CustomersController.php b/app/Http/Controllers/Api/CustomersController.php new file mode 100644 index 0000000..d759a8d --- /dev/null +++ b/app/Http/Controllers/Api/CustomersController.php @@ -0,0 +1,130 @@ +orderBy('id', 'desc'); + if ($request->has('search') &&!empty($request->get('search'))) { + $query = $query->where('nomor_pelanggan', 'LIKE', '%'.$request->get('search').'%') + ->orWhere('nama', 'LIKE', '%'.$request->get('search').'%') + ->orWhere('kota_palayanan', 'LIKE', '%'.$request->get('search').'%'); + } + return CustomersResource::collection($query->paginate()); + } + + /** + * Store a newly created resource in storage. + */ + public function store(CustomersRequest $request) + { + try{ + $customer = Customer::create($request->validated()); + return response()->json(['message' => 'Successfully created', new CustomersResource($customer)]); + }catch(\Exception $e){ + return response()->json([ + 'message' => 'Failed to create customer', + 'error' => $e->getMessage() + ], 500); + } + } + + /** + * Display the specified resource. + */ + public function show(string $id) + { + try{ + $customer = Customer::find($id); + if($customer){ + return new CustomersResource($customer); + } else { + return response()->json(['message' => 'Customer not found'], 404); + } + }catch(\Exception $e){ + return response()->json([ + 'message' => 'Failed to retrieve customer', + 'error' => $e->getMessage() + ], 500); + } + } + + /** + * Update the specified resource in storage. + */ + public function update(CustomersRequest $request, string $id) + { + try{ + $customer = Customer::find($id); + if($customer){ + $customer->update($request->validated()); + return response()->json(['message' => 'Successfully updated', new CustomersResource($customer)]); + } else { + return response()->json(['message' => 'Customer not found'], 404); + } + }catch(\Exception $e) { + return response()->json([ + 'message' => 'Failed to update customer', + 'error' => $e->getMessage() + ], 500); + } + } + + /** + * Remove the specified resource from storage. + */ + public function destroy(string $id) + { + try{ + $customer = Customer::find($id); + if($customer){ + $customer->delete(); + return response()->json(['message' => 'Successfully deleted']); + }else { + return response()->json(['message' => 'Customer not found'], 404); + } + }catch(\Exception $e) { + return response()->json([ + 'message' => 'Failed to delete customer', + 'error' => $e->getMessage() + ], 500); + } + } + + public function upload(ExcelUploadRequest $request){ + try{ + if(!$request->hasFile('file')){ + return response()->json([ + 'error' => 'No file provided' + ], 400); + } + + $file = $request->file('file'); + Excel::import(new CustomersImport, $file); + + return response()->json([ + 'message' => 'File uploaded successfully', + ]); + }catch(\Exception $e){ + \Log::info($e->getMessage()); + return response()->json([ + 'error' => 'Failed to upload file', + 'message' => $e->getMessage() + ], 500); + } + } +} diff --git a/app/Http/Controllers/Api/SpatialPlanningController.php b/app/Http/Controllers/Api/SpatialPlanningController.php new file mode 100644 index 0000000..7635ab7 --- /dev/null +++ b/app/Http/Controllers/Api/SpatialPlanningController.php @@ -0,0 +1,146 @@ +input('per_page', 15); + $search = $request->input('search', ''); + + $query = SpatialPlanning::query(); + if ($search) { + $query->where(function ($q) use ($search) { + $q->where('name', 'like', "%$search%") + ->orWhere('kbli', 'like', "%$search%") + ->orWhere('activities', 'like', "%$search%") + ->orWhere('area', 'like', "%$search%") + ->orWhere('location', 'like', "%$search%") + ->orWhere('number', 'like', "%$search%"); + }); + } + + $spatialPlannings = $query->paginate($perPage); + + // Menambhakan nomor urut (No) + $start = ($spatialPlannings->currentPage()-1) * $perPage + 1; + + // Tambahkan nomor urut ke dalam data + $data = $spatialPlannings->map(function ($item, $index) use ($start) { + return array_merge($item->toArray(), ['no' => $start + $index]); + }); + + info($data); + + return response()->json([ + 'data' => $data, + 'meta' => [ + 'total' => $spatialPlannings->total(), + 'per_page' => $spatialPlannings->perPage(), + 'current_page' => $spatialPlannings->currentPage(), + 'last_page'=>$spatialPlannings->lastPage(), + ] + ]); + } + + /** + * Store a newly created resource in storage. + */ + public function store(SpatialPlanningRequest $request): SpatialPlanning + { + $data = $request->validated(); + return SpatialPlanning::create($data); + } + + /** + * import spatial planning from excel + */ + public function importFromFile(Request $request) + { + info($request); + //validasi file + $validator = Validator::make($request->all(), [ + 'file' => 'required|mimes:xlsx, xls|max:10240' + ]); + + if ($validator->fails()) { + return response()->json([ + 'message'=>'File vaildation failed.', + "errors"=>$validator->errors() + ], 400); + } + + try { + $file = $request->file('file'); + Excel::import(new SpatialPlanningImport, $file); + return response()->json([ + 'message'=>'File uploaded and imported successfully!' + ], 200); + } catch (\Exception $e) { + return response()->json([ + 'message'=>'Error during file import.', + 'error'=>$e->getMessage() + ], 500); + } + } + + /** + * Display the specified resource. + */ + public function show(SpatialPlanning $spatialPlanning): SpatialPlanning + { + return $spatialPlanning; + } + + /** + * Update the specified resource in storage. + */ + public function update(SpatialPlanningRequest $request, SpatialPlanning $spatialPlanning): SpatialPlanning + { + info($request); + $data = $request->validated(); + info($data); + + $spatialPlanning->update($data); + + return $spatialPlanning; + } + + public function destroy(SpatialPlanning $spatialPlanning): Response + { + $spatialPlanning->delete(); + + return response()->noContent(); + } + + public function downloadExcelSpatialPlanning() + { + $filePath = public_path('templates/template_spatial_planning.xlsx'); + info(sprintf("File Path: %s | Exists: %s", $filePath, file_exists($filePath) ? 'Yes' : 'No')); + + // Cek apakah file ada + if (!file_exists($filePath)) { + return response()-> json(['message' => 'File tidak ditemukan!'], Response::HTTP_NOT_FOUND); + } + + // Return file to download + return response()->download($filePath); + } +} diff --git a/app/Http/Controllers/Api/TourismController.php b/app/Http/Controllers/Api/TourismController.php index c39a18f..896ff79 100644 --- a/app/Http/Controllers/Api/TourismController.php +++ b/app/Http/Controllers/Api/TourismController.php @@ -25,6 +25,13 @@ class TourismController extends Controller $search = $request->input('search', ''); $query = Tourism::query(); + if ($search) { + $query->where(function ($q) use ($search) { + $q->where('business_name', 'like', "%$search%") + ->orWhere('project_name', 'like', "%$search%") + ->orWhere('business_address', 'like', "%$search%"); + }); + } $tourisms = $query->paginate($perPage); $tourisms->getCollection()->transform(function ($tourisms) { @@ -36,8 +43,14 @@ class TourismController extends Controller return $tourisms; }); + $start = ($tourisms->currentPage()-1) * $perPage + 1; + + $data = $tourisms->map(function ($item, $index) use ($start) { + return array_merge($item->toArray(), ['no' => $start + $index]); + }); + return response()->json([ - 'data' => TourismResource::collection($tourisms), + 'data' => $data, 'meta' => [ 'total' => $tourisms->total(), 'per_page' => $tourisms->perPage(), @@ -127,4 +140,18 @@ class TourismController extends Controller return response()->noContent(); } + + public function downloadExcelTourism() + { + $filePath = public_path('templates/template_pariwisata.xlsx'); + info(sprintf("File Path: %s | Exists: %s", $filePath, file_exists($filePath) ? 'Yes' : 'No')); + + // Cek apakah file ada + if (!file_exists($filePath)) { + return response()-> json(['message' => 'File tidak ditemukan!'], Response::HTTP_NOT_FOUND); + } + + // Return file to download + return response()->download($filePath); + } } diff --git a/app/Http/Controllers/Api/UmkmController.php b/app/Http/Controllers/Api/UmkmController.php index 4ecf63e..b35fe01 100644 --- a/app/Http/Controllers/Api/UmkmController.php +++ b/app/Http/Controllers/Api/UmkmController.php @@ -27,6 +27,17 @@ class UmkmController extends Controller $query = Umkm::query(); + if ($search) { + $query->where(function ($q) use ($search) { + $q->where('business_name', 'like', "%$search%") + ->orWhere('business_address', 'like', "%$search%") + ->orWhere('business_desc', 'like', "%$search%") + ->orWhere('business_id_number', 'like', "%$search%") + ->orWhere('owner_id', 'like', "%$search%") + ->orWhere('owner_name', 'like', "%$search%"); + }); + } + $umkm = $query->paginate($perPage); $umkm->getCollection()->transform(function ($umkm) { @@ -47,8 +58,14 @@ class UmkmController extends Controller return $umkm; }); + $start = ($umkm->currentPage()-1) * $perPage + 1; + + $data = $umkm->map(function ($item, $index) use ($start) { + return array_merge($item->toArray(), ['no' => $start + $index]); + }); + return response()->json([ - 'data' => UmkmResource::collection($umkm), + 'data' => $data, 'meta' => [ 'total' => $umkm->total(), 'per_page' => $umkm->perPage(), @@ -176,7 +193,7 @@ class UmkmController extends Controller public function downloadExcelUmkm() { - $filePath = storage_path('app/public/templates/template_umkm.xlsx'); + $filePath = public_path('templates/template_umkm.xlsx'); // Cek apakah file ada if (!file_exists($filePath)) { diff --git a/app/Http/Controllers/CustomersController.php b/app/Http/Controllers/CustomersController.php new file mode 100644 index 0000000..9c0c8ec --- /dev/null +++ b/app/Http/Controllers/CustomersController.php @@ -0,0 +1,26 @@ +getFields(); + $fieldTypes = $this->getFieldTypes(); + + $apiUrl = url('/api/spatial-plannings'); + return view('data.spatialPlannings.form', compact('title', 'subtitle', 'fields', 'fieldTypes', 'apiUrl', 'dropdownOptions')); + } + + /** + * Store a newly created resource in storage. + */ + public function store(Request $request) + { + // + } + + /** + * Display the specified resource. + */ + public function show(string $id) + { + // + } + + /** + * Show the form for editing the specified resource. + */ + public function edit(string $id) + { + $title = 'Rencana Tata Ruang'; + $subtitle = 'Update Data'; + + $modelInstance = SpatialPlanning::find($id); + // Pastikan model ditemukan + if (!$modelInstance) { + return redirect()->route('spatialPlanning.index') ->with('error', 'Rencana tata ruang tidak ditemukan'); + } + + $dropdownOptions = []; + + $fields = $this->getFields(); + $fieldTypes = $this->getFieldTypes(); + + $apiUrl = url('/api/spatial-plannings'); + return view('data.spatialPlannings.form', compact('title', 'subtitle', 'modelInstance', 'fields', 'fieldTypes', 'apiUrl', 'dropdownOptions')); + } + + /** + * Update the specified resource in storage. + */ + public function update(Request $request, string $id) + { + // + } + + /** + * Remove the specified resource from storage. + */ + public function destroy(string $id) + { + // + } + + private function getFields() + { + return [ + "name"=> "Nama", + "kbli"=> "KBLI", + "activities"=> "Kegiatan", + "area"=> "Luas (m2)", + "location"=> "Lokasi", + "number"=> "Nomor", + "date"=> "Tanggal", + ]; + } + + private function getFieldTypes() + { + return [ + "name"=> "text", + "kbli"=> "text", + "activities"=> "text", + "area"=> "text", + "location"=> "text", + "number"=> "text", + "date"=> "date", + ]; + } +} diff --git a/app/Http/Controllers/Data/TourismController.php b/app/Http/Controllers/Data/TourismController.php index 5facbb5..87d4379 100644 --- a/app/Http/Controllers/Data/TourismController.php +++ b/app/Http/Controllers/Data/TourismController.php @@ -53,7 +53,7 @@ class TourismController extends Controller public function edit($id) { $title = 'Pariwisata'; - $subtitle = 'Create Data'; + $subtitle = 'Update Data'; $modelInstance = Tourism::find($id); // Pastikan model ditemukan diff --git a/app/Http/Requests/AdvertisementRequest.php b/app/Http/Requests/AdvertisementRequest.php index c2f29a8..80ca222 100644 --- a/app/Http/Requests/AdvertisementRequest.php +++ b/app/Http/Requests/AdvertisementRequest.php @@ -40,4 +40,40 @@ class AdvertisementRequest extends FormRequest 'contact' => 'required|string', ]; } + + /** + * pesan error validasi + */ + public function messages(): array + { + return [ + 'no.required' => 'Nomor harus diisi.', + 'business_name.required' => 'Nama usaha harus diisi.', + 'business_name.string' => 'Nama usaha harus berupa teks.', + 'npwpd.required' => 'NPWPD harus diisi.', + 'npwpd.string' => 'NPWPD harus berupa teks.', + 'advertisement_type.required' => 'Jenis reklame harus diisi.', + 'advertisement_type.string' => 'Jenis reklame harus berupa teks.', + 'advertisement_content.required' => 'Isi reklame harus diisi.', + 'advertisement_content.string' => 'Isi reklame harus berupa teks.', + 'business_address.required' => 'Alamat usaha harus diisi.', + 'business_address.string' => 'Alamat usaha harus berupa teks.', + 'advertisement_location.required' => 'Lokasi reklame harus diisi.', + 'advertisement_location.string' => 'Lokasi reklame harus berupa teks.', + 'village_name.required' => 'Nama desa harus diisi.', + 'district_name.required' => 'Nama kecamatan harus diisi.', + 'length.required' => 'Panjang harus diisi.', + 'width.required' => 'Lebar harus diisi.', + 'viewing_angle.required' => 'Sudut pandang harus diisi.', + 'viewing_angle.string' => 'Sudut pandang harus berupa teks.', + 'face.required' => 'Jumlah sisi harus diisi.', + 'face.string' => 'Jumlah sisi harus berupa teks.', + 'area.required' => 'Luas harus diisi.', + 'area.string' => 'Luas harus berupa teks.', + 'angle.required' => 'Sudut harus diisi.', + 'angle.string' => 'Sudut harus berupa teks.', + 'contact.required' => 'Kontak harus diisi.', + 'contact.string' => 'Kontak harus berupa teks.', + ]; + } } diff --git a/app/Http/Requests/CustomersRequest.php b/app/Http/Requests/CustomersRequest.php new file mode 100644 index 0000000..021f4a3 --- /dev/null +++ b/app/Http/Requests/CustomersRequest.php @@ -0,0 +1,33 @@ +|string> + */ + public function rules(): array + { + return [ + 'nomor_pelanggan' => ['required', 'string'], + 'kota_pelayanan' => ['required', 'string'], + 'nama' => ['required', 'string'], + 'alamat' => ['required', 'string'], + 'latitude' => ['required', 'numeric', 'between:-90,90'], + 'longitude' => ['required', 'numeric', 'between:-180,180'], + ]; + } +} diff --git a/app/Http/Requests/ExcelUploadRequest.php b/app/Http/Requests/ExcelUploadRequest.php new file mode 100644 index 0000000..ad492ca --- /dev/null +++ b/app/Http/Requests/ExcelUploadRequest.php @@ -0,0 +1,28 @@ +|string> + */ + public function rules(): array + { + return [ + "file" => "required|file|mimes:xlsx,xls|max:102400" + ]; + } +} diff --git a/app/Http/Requests/SpatialPlanningRequest.php b/app/Http/Requests/SpatialPlanningRequest.php new file mode 100644 index 0000000..853d646 --- /dev/null +++ b/app/Http/Requests/SpatialPlanningRequest.php @@ -0,0 +1,52 @@ +|string> + */ + public function rules(): array + { + return [ + 'name' => 'string', + 'kbli' => 'string', + 'activities' => 'string', + 'area' => 'string', + 'location' => 'string', + 'number' => 'string', + 'date' => 'date_format:Y-m-d', + ]; + } + + /** + * Get the validation messages for the defined validation rules. + * + * @return array + */ + public function messages(): array + { + return [ + 'name.string' => 'Kolom Nama harus berupa teks.', + 'kbli.string' => 'Kolom KBLI harus berupa teks.', + 'activities.string' => 'Kolom Kegiatan harus berupa teks.', + 'area.string' => 'Kolom Area harus berupa teks.', + 'location.string' => 'Kolom Lokasi harus berupa teks.', + 'number.string' => 'Kolom Nomor harus berupa teks.', + 'date.date_format' => 'Format tanggal tidak valid, gunakan format Y-m-d H:i:s.', + ]; + } +} diff --git a/app/Http/Requests/SpatialPlanningsRequest.php b/app/Http/Requests/SpatialPlanningsRequest.php new file mode 100644 index 0000000..73971b4 --- /dev/null +++ b/app/Http/Requests/SpatialPlanningsRequest.php @@ -0,0 +1,35 @@ +|string> + */ + public function rules(): array + { + return [ + 'name' => ['required','string','max:255'], + 'kbli' => ['required','string','max:255'], + 'kegiatan' => ['required','string'], + 'luas' => ['required','numeric','regex:/^\d{1,16}(\.\d{1,2})?$/'], + 'lokasi' => ['required','string'], + 'nomor' => ['required','string','max:255',Rule::unique('spatial_plannings')->ignore($this->id)], + 'sp_date' => ['required','date'], + ]; + } +} diff --git a/app/Http/Requests/TourismRequest.php b/app/Http/Requests/TourismRequest.php index fc618cc..a7a503a 100644 --- a/app/Http/Requests/TourismRequest.php +++ b/app/Http/Requests/TourismRequest.php @@ -49,4 +49,85 @@ class TourismRequest extends FormRequest 'tki' => 'required|string', ]; } + + /** + * Get the validation messages for the defined validation rules. + * + * @return array + */ + public function messages(): array + { + return [ + 'project_id.required' => 'ID proyek harus diisi.', + 'project_id.string' => 'ID proyek harus berupa teks.', + + 'project_type_id.required' => 'ID tipe proyek harus diisi.', + 'project_type_id.string' => 'ID tipe proyek harus berupa teks.', + + 'nib.required' => 'NIB harus diisi.', + 'nib.string' => 'NIB harus berupa teks.', + + 'business_name.required' => 'Nama usaha harus diisi.', + 'business_name.string' => 'Nama usaha harus berupa teks.', + + 'oss_publication_date.required' => 'Tanggal publikasi OSS harus diisi.', + + 'investment_status_description.required' => 'Deskripsi status investasi harus diisi.', + 'investment_status_description.string' => 'Deskripsi status investasi harus berupa teks.', + + 'business_form.required' => 'Bentuk usaha harus diisi.', + 'business_form.string' => 'Bentuk usaha harus berupa teks.', + + 'project_risk.required' => 'Risiko proyek harus diisi.', + 'project_risk.string' => 'Risiko proyek harus berupa teks.', + + 'project_name.required' => 'Nama proyek harus diisi.', + 'project_name.string' => 'Nama proyek harus berupa teks.', + + 'business_scale.required' => 'Skala usaha harus diisi.', + 'business_scale.string' => 'Skala usaha harus berupa teks.', + + 'business_address.required' => 'Alamat usaha harus diisi.', + 'business_address.string' => 'Alamat usaha harus berupa teks.', + + 'district_name.required' => 'Nama kecamatan harus diisi.', + + 'village_name.required' => 'Nama desa harus diisi.', + + 'longitude.required' => 'Garis bujur harus diisi.', + 'longitude.string' => 'Garis bujur harus berupa teks.', + + 'latitude.required' => 'Garis lintang harus diisi.', + 'latitude.string' => 'Garis lintang harus berupa teks.', + + 'project_submission_date.required' => 'Tanggal pengajuan proyek harus diisi.', + + 'kbli.required' => 'Kode KBLI harus diisi.', + 'kbli.string' => 'Kode KBLI harus berupa teks.', + + 'kbli_title.required' => 'Judul KBLI harus diisi.', + 'kbli_title.string' => 'Judul KBLI harus berupa teks.', + + 'supervisory_sector.required' => 'Sektor pengawasan harus diisi.', + 'supervisory_sector.string' => 'Sektor pengawasan harus berupa teks.', + + 'user_name.required' => 'Nama pengguna harus diisi.', + 'user_name.string' => 'Nama pengguna harus berupa teks.', + + 'email.required' => 'Email harus diisi.', + 'email.string' => 'Email harus berupa teks.', + + 'contact.required' => 'Kontak harus diisi.', + 'contact.string' => 'Kontak harus berupa teks.', + + 'land_area_in_m2.required' => 'Luas lahan dalam m² harus diisi.', + 'land_area_in_m2.string' => 'Luas lahan dalam m² harus berupa teks.', + + 'investment_amount.required' => 'Jumlah investasi harus diisi.', + 'investment_amount.string' => 'Jumlah investasi harus berupa teks.', + + 'tki.required' => 'Jumlah tenaga kerja Indonesia harus diisi.', + 'tki.string' => 'Jumlah tenaga kerja Indonesia harus berupa teks.', + ]; + } } diff --git a/app/Http/Resources/CustomersResource.php b/app/Http/Resources/CustomersResource.php new file mode 100644 index 0000000..2b48c64 --- /dev/null +++ b/app/Http/Resources/CustomersResource.php @@ -0,0 +1,19 @@ + + */ + public function toArray(Request $request): array + { + return parent::toArray($request); + } +} diff --git a/app/Http/Resources/SpatialPlanningResource.php b/app/Http/Resources/SpatialPlanningResource.php new file mode 100644 index 0000000..86b438b --- /dev/null +++ b/app/Http/Resources/SpatialPlanningResource.php @@ -0,0 +1,19 @@ + + */ + public function toArray(Request $request): array + { + return parent::toArray($request); + } +} diff --git a/app/Http/Resources/SpatialPlanningsResource.php b/app/Http/Resources/SpatialPlanningsResource.php new file mode 100644 index 0000000..40a29d9 --- /dev/null +++ b/app/Http/Resources/SpatialPlanningsResource.php @@ -0,0 +1,19 @@ + + */ + public function toArray(Request $request): array + { + return parent::toArray($request); + } +} diff --git a/app/Imports/CustomersImport.php b/app/Imports/CustomersImport.php new file mode 100644 index 0000000..e448faa --- /dev/null +++ b/app/Imports/CustomersImport.php @@ -0,0 +1,52 @@ +skip(1) as $row) { + if (!isset($row[0]) || empty($row[0])) { + continue; + } + + $latitude = filter_var($row[4], FILTER_VALIDATE_FLOAT) ? bcadd($row[4], '0', 18) : null; + $longitude = filter_var($row[5], FILTER_VALIDATE_FLOAT) ? bcadd($row[5], '0', 18) : null; + + $batchData[] = [ + 'nomor_pelanggan' => $row[0], + 'kota_pelayanan' => $row[1], + 'nama' => $row[2], + 'alamat' => $row[3], + 'latitude' => $latitude, + 'longitude' => $longitude, + ]; + } + + if (!empty($batchData)) { + Customer::upsert($batchData, ['nomor_pelanggan'], ['kota_pelayanan', 'nama', 'alamat', 'latitude', 'longitude']); + } + } + + public function sheets(): array { + return [ + 0 => $this + ]; + } +} diff --git a/app/Imports/SpatialPlanningImport.php b/app/Imports/SpatialPlanningImport.php new file mode 100644 index 0000000..41fb5aa --- /dev/null +++ b/app/Imports/SpatialPlanningImport.php @@ -0,0 +1,63 @@ +isEmpty()) + { + return; + } + + //cari header secara otomatis + $header = $rows->first(); + $headerIndex = collect($header)->search(fn($value) => !empty($value)); + + // Pastikan header ditemukan + if ($headerIndex === false) { + return; + } + + foreach ($rows->skip(1) as $row) { + $dateValue = trim($row[7]); + info($dateValue); + $parsedDate = Carbon::createFromFormat('Y-m-d', $dateValue)->format('Y-m-d'); + info($parsedDate); + + $dataToInsert[] = [ + 'name'=>$row[1], + 'kbli'=>$row[2], + 'activities'=>$row[3], + 'area'=>$row[4], + 'location'=>$row[5], + 'number'=>$row[6], + 'date'=>$parsedDate, + ]; + } + + if(!empty($dataToInsert)) { + SpatialPlanning::insert($dataToInsert); + } else { + return; + } + } +} diff --git a/app/Imports/TourismImport.php b/app/Imports/TourismImport.php index 122f761..b8967eb 100644 --- a/app/Imports/TourismImport.php +++ b/app/Imports/TourismImport.php @@ -65,13 +65,6 @@ class TourismImport implements ToCollection // ambill village code yang village_name sama dengan $villageName $villageCode = $listTrueVillage[$villageName]['village_code'] ?? '000000'; - - // if (empty($row[16])) { - // info("Data kosong"); - // } else { - // info("Baris ke- | Nilai: " . $row[16]); - // } - $excelSerialDate = $row[16]; if (is_numeric($excelSerialDate)) { $projectSubmissionDate = Carbon::createFromFormat('Y-m-d', '1899-12-30') @@ -82,8 +75,6 @@ class TourismImport implements ToCollection ->format('Y-m-d H:i:s'); } - info("Tanggal dikonversi: " . $projectSubmissionDate); - $dataToInsert[] = [ 'project_id' => $row[1], 'project_type_id' => $row[2], diff --git a/app/Models/Customer.php b/app/Models/Customer.php new file mode 100644 index 0000000..b50d890 --- /dev/null +++ b/app/Models/Customer.php @@ -0,0 +1,20 @@ + + */ + protected $fillable = ['name', 'kbli', 'activities', 'area', 'location', 'number', 'date']; + + +} diff --git a/composer.json b/composer.json index be9022c..755703d 100755 --- a/composer.json +++ b/composer.json @@ -19,7 +19,6 @@ }, "require-dev": { "fakerphp/faker": "^1.23", - "ibex/crud-generator": "^2.1", "laravel/pail": "^1.1", "laravel/pint": "^1.13", "laravel/sail": "^1.26", diff --git a/database/migrations/2025_02_20_050004_create_spatial_planning_table.php b/database/migrations/2025_02_20_050004_create_spatial_planning_table.php new file mode 100644 index 0000000..e7ca0fc --- /dev/null +++ b/database/migrations/2025_02_20_050004_create_spatial_planning_table.php @@ -0,0 +1,35 @@ +id(); + $table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP')); + $table->timestamp('updated_at')->default(DB::raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP')); + $table->string('name')->nullable(); + $table->string('kbli')->nullable(); + $table->string('activities')->nullable(); + $table->string('area')->nullable(); + $table->string('location')->nullable(); + $table->string('number')->nullable(); + $table->dateTime('date')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('spatial_planning'); + } +}; diff --git a/database/migrations/2025_02_20_073855_rename_spatial_planning_table.php b/database/migrations/2025_02_20_073855_rename_spatial_planning_table.php new file mode 100644 index 0000000..b940552 --- /dev/null +++ b/database/migrations/2025_02_20_073855_rename_spatial_planning_table.php @@ -0,0 +1,24 @@ +id(); + $table->string('nomor_pelanggan')->unique(); + $table->string('kota_pelayanan'); + $table->string('nama'); + $table->text('alamat'); + $table->decimal('latitude', 22,18); + $table->decimal('longitude', 22,18); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('customers'); + } +}; diff --git a/database/seeders/UsersRoleMenuSeeder.php b/database/seeders/UsersRoleMenuSeeder.php index 84b7625..17c2c0a 100644 --- a/database/seeders/UsersRoleMenuSeeder.php +++ b/database/seeders/UsersRoleMenuSeeder.php @@ -186,6 +186,20 @@ class UsersRoleMenuSeeder extends Seeder "parent_id" => $data->id, "sort_order" => 5, ], + [ + "name" => "Tata Ruang", + "url" => "spatial-plannings.index", + "icon" => null, + "parent_id" => $data->id, + "sort_order" => 6, + ], + [ + "name" => "PDAM", + "url" => "customers", + "icon" => null, + "parent_id" => $data->id, + "sort_order" => 7, + ], [ "name" => "Lap Pariwisata", "url" => "tourisms.index", @@ -213,6 +227,8 @@ class UsersRoleMenuSeeder extends Seeder $laporan_pariwisata = Menu::where('name', 'Lap Pariwisata')->first(); $umkm = Menu::where('name', 'UMKM')->first(); $lack_of_potentials = Menu::where('name', 'Dashboard Potensi')->first(); + $spatial_plannings = Menu::where('name', 'Tata Ruang')->first(); + $pdam = Menu::where('name', 'PDAM')->first(); // Superadmin gets all menus $superadmin->menus()->sync([ @@ -238,6 +254,8 @@ class UsersRoleMenuSeeder extends Seeder $laporan_pariwisata->id => ["allow_show" => true, "allow_create" => true, "allow_update" => true, "allow_destroy" => true], $umkm->id => ["allow_show" => true, "allow_create" => true, "allow_update" => true, "allow_destroy" => true], $lack_of_potentials->id => ["allow_show" => true, "allow_create" => true, "allow_update" => true, "allow_destroy" => true], + $spatial_plannings->id => ["allow_show" => true, "allow_create" => true, "allow_update" => true, "allow_destroy" => true], + $pdam->id => ["allow_show" => true, "allow_create" => true, "allow_update" => true, "allow_destroy" => true], ]); // Admin gets limited menus diff --git a/public/templates/template_pariwisata.xlsx b/public/templates/template_pariwisata.xlsx new file mode 100644 index 0000000..13de764 Binary files /dev/null and b/public/templates/template_pariwisata.xlsx differ diff --git a/public/templates/template_spatial_planning.xlsx b/public/templates/template_spatial_planning.xlsx new file mode 100644 index 0000000..d7506a5 Binary files /dev/null and b/public/templates/template_spatial_planning.xlsx differ diff --git a/resources/js/customers/create.js b/resources/js/customers/create.js new file mode 100644 index 0000000..23aa7af --- /dev/null +++ b/resources/js/customers/create.js @@ -0,0 +1,65 @@ +class CreateCustomer { + constructor() { + this.initCreateCustomer(); + } + + initCreateCustomer() { + const toastNotification = document.getElementById("toastNotification"); + const toast = new bootstrap.Toast(toastNotification); + document + .getElementById("btnCreateCustomer") + .addEventListener("click", async function () { + let submitButton = this; + let spinner = document.getElementById("spinner"); + let form = document.getElementById("formCreateCustomer"); + + if (!form) { + console.error("Form element not found!"); + return; + } + // Get form data + let formData = new FormData(form); + + // Disable button and show spinner + submitButton.disabled = true; + spinner.classList.remove("d-none"); + + try { + let response = await fetch(form.action, { + method: "POST", + headers: { + Authorization: `Bearer ${document + .querySelector('meta[name="api-token"]') + .getAttribute("content")}`, + }, + body: formData, + }); + + if (response.ok) { + let result = await response.json(); + document.getElementById("toast-message").innerText = + result.message; + toast.show(); + setTimeout(() => { + window.location.href = "/data/customers"; + }, 2000); + } else { + let error = await response.json(); + document.getElementById("toast-message").innerText = + error.message; + toast.show(); + console.error("Error:", error); + } + } catch (error) { + console.error("Request failed:", error); + document.getElementById("toast-message").innerText = + error.message; + toast.show(); + } + }); + } +} + +document.addEventListener("DOMContentLoaded", function (e) { + new CreateCustomer(); +}); diff --git a/resources/js/customers/edit.js b/resources/js/customers/edit.js new file mode 100644 index 0000000..b59b4b8 --- /dev/null +++ b/resources/js/customers/edit.js @@ -0,0 +1,65 @@ +class UpdateCustomer { + constructor() { + this.initUpdateSpatial(); + } + + initUpdateSpatial() { + const toastNotification = document.getElementById("toastNotification"); + const toast = new bootstrap.Toast(toastNotification); + document + .getElementById("btnUpdateCustomer") + .addEventListener("click", async function () { + let submitButton = this; + let spinner = document.getElementById("spinner"); + let form = document.getElementById("formUpdateCustomer"); + + if (!form) { + console.error("Form element not found!"); + return; + } + // Get form data + let formData = new FormData(form); + + // Disable button and show spinner + submitButton.disabled = true; + spinner.classList.remove("d-none"); + + try { + let response = await fetch(form.action, { + method: "POST", + headers: { + Authorization: `Bearer ${document + .querySelector('meta[name="api-token"]') + .getAttribute("content")}`, + }, + body: formData, + }); + + if (response.ok) { + let result = await response.json(); + document.getElementById("toast-message").innerText = + result.message; + toast.show(); + setTimeout(() => { + window.location.href = "/data/customers"; + }, 2000); + } else { + let error = await response.json(); + document.getElementById("toast-message").innerText = + error.message; + toast.show(); + console.error("Error:", error); + } + } catch (error) { + console.error("Request failed:", error); + document.getElementById("toast-message").innerText = + error.message; + toast.show(); + } + }); + } +} + +document.addEventListener("DOMContentLoaded", function (e) { + new UpdateCustomer(); +}); diff --git a/resources/js/customers/index.js b/resources/js/customers/index.js new file mode 100644 index 0000000..9141ae5 --- /dev/null +++ b/resources/js/customers/index.js @@ -0,0 +1,151 @@ +import { Grid } from "gridjs/dist/gridjs.umd.js"; +import gridjs from "gridjs/dist/gridjs.umd.js"; +import "gridjs/dist/gridjs.umd.js"; +import GlobalConfig from "../global-config"; +import Swal from "sweetalert2"; + +class Customers { + constructor() { + this.toastMessage = document.getElementById("toast-message"); + this.toastElement = document.getElementById("toastNotification"); + this.toast = new bootstrap.Toast(this.toastElement); + this.table = null; + + // Initialize functions + this.initTableSpatialPlannings(); + this.initEvents(); + } + initEvents() { + document.body.addEventListener("click", async (event) => { + const deleteButton = event.target.closest(".btn-delete-customers"); + if (deleteButton) { + event.preventDefault(); + await this.handleDelete(deleteButton); + } + }); + } + + initTableSpatialPlannings() { + let tableContainer = document.getElementById("table-customers"); + // Create a new Grid.js instance only if it doesn't exist + this.table = new Grid({ + columns: [ + "ID", + "Nomor Pelanggan", + "Nama", + "Kota Pelayanan", + "Alamat", + "Latitude", + "Longitude", + { + name: "Action", + formatter: (cell) => + gridjs.html(` +
+ + + + +
+ `), + }, + ], + pagination: { + limit: 15, + server: { + url: (prev, page) => + `${prev}${prev.includes("?") ? "&" : "?"}page=${ + page + 1 + }`, + }, + }, + sort: true, + search: { + server: { + url: (prev, keyword) => `${prev}?search=${keyword}`, + }, + }, + server: { + url: `${GlobalConfig.apiHost}/api/customers`, + headers: { + Authorization: `Bearer ${document + .querySelector('meta[name="api-token"]') + .getAttribute("content")}`, + "Content-Type": "application/json", + }, + then: (data) => + data.data.map((item) => [ + item.id, + item.nomor_pelanggan, + item.nama, + item.kota_pelayanan, + item.alamat, + item.latitude, + item.longitude, + item.id, + ]), + total: (data) => data.meta.total, + }, + }).render(tableContainer); + } + + async handleDelete(deleteButton) { + const id = deleteButton.getAttribute("data-id"); + + const result = await Swal.fire({ + title: "Are you sure?", + text: "You won't be able to revert this!", + icon: "warning", + showCancelButton: true, + confirmButtonColor: "#3085d6", + cancelButtonColor: "#d33", + confirmButtonText: "Yes, delete it!", + }); + + if (result.isConfirmed) { + try { + let response = await fetch( + `${GlobalConfig.apiHost}/api/customers/${id}`, + { + method: "DELETE", + credentials: "include", + headers: { + Authorization: `Bearer ${document + .querySelector('meta[name="api-token"]') + .getAttribute("content")}`, + "Content-Type": "application/json", + }, + } + ); + + if (response.ok) { + let result = await response.json(); + this.toastMessage.innerText = + result.message || "Deleted successfully!"; + this.toast.show(); + + // Refresh Grid.js table + if (typeof this.table !== "undefined") { + this.table.updateConfig({}).forceRender(); + } + } else { + let error = await response.json(); + console.error("Delete failed:", error); + this.toastMessage.innerText = + error.message || "Delete failed!"; + this.toast.show(); + } + } catch (error) { + console.error("Error deleting item:", error); + this.toastMessage.innerText = "An error occurred!"; + this.toast.show(); + } + } + } +} + +document.addEventListener("DOMContentLoaded", function (e) { + new Customers(); +}); diff --git a/resources/js/customers/upload.js b/resources/js/customers/upload.js new file mode 100644 index 0000000..8133c35 --- /dev/null +++ b/resources/js/customers/upload.js @@ -0,0 +1,78 @@ +import { Dropzone } from "dropzone"; +Dropzone.autoDiscover = false; + +class UploadCustomers { + constructor() { + this.spatialDropzone = null; + this.formElement = document.getElementById("formUploadCustomers"); + this.uploadButton = document.getElementById("submit-upload"); + this.spinner = document.getElementById("spinner"); + if (!this.formElement) { + console.error("Element formUploadCustomers tidak ditemukan!"); + } + } + + init() { + this.initDropzone(); + this.setupUploadButton(); + } + + initDropzone() { + const toastNotification = document.getElementById("toastNotification"); + const toast = new bootstrap.Toast(toastNotification); + var previewTemplate, + dropzonePreviewNode = document.querySelector( + "#dropzone-preview-list" + ); + (dropzonePreviewNode.id = ""), + dropzonePreviewNode && + ((previewTemplate = dropzonePreviewNode.parentNode.innerHTML), + dropzonePreviewNode.parentNode.removeChild(dropzonePreviewNode), + (this.spatialDropzone = new Dropzone(".dropzone", { + url: this.formElement.action, + method: "post", + acceptedFiles: ".xls,.xlsx", + previewTemplate: previewTemplate, + previewsContainer: "#dropzone-preview", + autoProcessQueue: false, + headers: { + Authorization: `Bearer ${document + .querySelector('meta[name="api-token"]') + .getAttribute("content")}`, + }, + init: function () { + this.on("success", function (file, response) { + document.getElementById("toast-message").innerText = + response.message; + toast.show(); + setTimeout(() => { + window.location.href = "/data/customers"; + }, 2000); + }); + this.on("error", function (file, errorMessage) { + document.getElementById("toast-message").innerText = + errorMessage.message; + toast.show(); + this.uploadButton.disabled = false; + this.spinner.classList.add("d-none"); + }); + }, + }))); + } + + setupUploadButton() { + this.uploadButton.addEventListener("click", (e) => { + if (this.spatialDropzone.files.length > 0) { + this.spatialDropzone.processQueue(); + this.uploadButton.disabled = true; + this.spinner.classList.remove("d-none"); + } else { + return; + } + }); + } +} + +document.addEventListener("DOMContentLoaded", function (e) { + new UploadCustomers().init(); +}); diff --git a/resources/js/data/advertisements/form-create-update.js b/resources/js/data/advertisements/form-create-update.js index b22bb16..95a2edc 100644 --- a/resources/js/data/advertisements/form-create-update.js +++ b/resources/js/data/advertisements/form-create-update.js @@ -28,12 +28,7 @@ document.addEventListener("DOMContentLoaded", function () { data[key] = value; }); - // Log semua data dalam FormData - for (let pair of formData.entries()) { - console.log(pair[0] + ": " + pair[1]); - } const url = form.getAttribute("action"); - console.log("Ini adalah url dari form action", url); const method = isEdit ? "PUT" : "POST"; @@ -49,7 +44,6 @@ document.addEventListener("DOMContentLoaded", function () { }) .then(response => response.json()) .then(data => { - console.log("Response data:", data); if (!data.errors) { // Remove existing icon (if any) before adding the new one if (authLogo) { @@ -74,11 +68,11 @@ document.addEventListener("DOMContentLoaded", function () { toast.classList.add('show'); // Show the toast setTimeout(() => { toast.classList.remove('show'); // Hide the toast after 3 seconds - }, 3000); + }, 2000); setTimeout(() => { window.location.href = '/data/advertisements'; - }, 3000); + }, 1000); } else { if (authLogo) { // Hapus ikon yang sudah ada jika ada @@ -96,21 +90,21 @@ document.addEventListener("DOMContentLoaded", function () { // Tambahkan ikon ke dalam auth-logo authLogo.appendChild(icon); } - // Set error message for the toast - toastBody.textContent = "Error: " + (responseData.message || "Something went wrong"); - toast.classList.add('show'); // Show the toast // Enable button and reset its text on error modalButton.disabled = false; modalButton.innerHTML = isEdit ? "Update" : "Create"; + // Set error message for the toast + toastBody.textContent = "Failed: " + (data.message || "Something went wrong"); + toast.classList.add('show'); // Show the toast + setTimeout(() => { toast.classList.remove('show'); // Hide the toast after 3 seconds }, 3000); } }) - .catch(error => { - console.error("Error:", error); + .catch(errors => { if (authLogo) { // Hapus ikon yang sudah ada jika ada const existingIcon = authLogo.querySelector('.bx'); @@ -127,14 +121,14 @@ document.addEventListener("DOMContentLoaded", function () { // Tambahkan ikon ke dalam auth-logo authLogo.appendChild(icon); } + // Enable button and reset its text on error + modalButton.disabled = false; + modalButton.innerHTML = isEdit ? "Update" : "Create"; + // Set error message for the toast toastBody.textContent = "An error occurred while processing your request."; toast.classList.add('show'); // Show the toast - // Enable button and reset its text on error - modalButton.disabled = false; - modalButton.innerHTML = isEdit ? "Update" : "Create"; - setTimeout(() => { toast.classList.remove('show'); // Hide the toast after 3 seconds }, 3000); @@ -144,7 +138,6 @@ document.addEventListener("DOMContentLoaded", function () { // Fungsi fetchOptions untuk autocomplete server-side window.fetchOptions = function (field) { let inputValue = document.getElementById(field).value; - console.log("Query Value:", inputValue); // Debugging log if (inputValue.length < 2) return; let districtValue = document.getElementById("district_name").value; // Ambil kecamatan terpilih diff --git a/resources/js/data/spatialPlannings/data-spatialPlannings.js b/resources/js/data/spatialPlannings/data-spatialPlannings.js new file mode 100644 index 0000000..b766e32 --- /dev/null +++ b/resources/js/data/spatialPlannings/data-spatialPlannings.js @@ -0,0 +1,63 @@ +import { Grid } from "gridjs/dist/gridjs.umd.js"; +import gridjs from "gridjs/dist/gridjs.umd.js"; +import "gridjs/dist/gridjs.umd.js"; +import GlobalConfig from "../../global-config.js"; +import GeneralTable from "../../table-generator.js"; + +const dataSpatialPlanningColumns = [ + "No", + "Nama", + "KBLI", + "Kegiatan", + "Luas", + "Lokasi", + "Nomor", + "Tanggal", + { + name: "Actions", + widht: "120px", + formatter: function (cell, row) { + const id = row.cells[8].data; + const model = "data/spatial-plannings"; + return gridjs.html(` +
+ + + +
+ `); + }, + }, +]; + +document.addEventListener("DOMContentLoaded", () => { + const table = new GeneralTable( + "spatial-planning-data-table", + `${GlobalConfig.apiHost}/api/spatial-plannings`, + `${GlobalConfig.apiHost}`, + dataSpatialPlanningColumns + ); + + table.processData = function (data) { + return data.data.map((item) => { + return [ + item.no, + item.name, + item.kbli, + item.activities, + item.area, + item.location, + item.number, + item.date, + item.id, + ]; + }); + }; + + table.init(); +}); diff --git a/resources/js/data/spatialPlannings/form-create-update.js b/resources/js/data/spatialPlannings/form-create-update.js new file mode 100644 index 0000000..f65687e --- /dev/null +++ b/resources/js/data/spatialPlannings/form-create-update.js @@ -0,0 +1,185 @@ +import GlobalConfig from "../../global-config"; + +document.addEventListener("DOMContentLoaded", function () { + const saveButton = document.querySelector(".modal-footer .btn-primary"); + const modalButton = document.querySelector(".btn-modal"); + const form = document.querySelector("form#create-update-form"); + var authLogo = document.querySelector(".auth-logo"); + + if (!saveButton || !form) return; + + saveButton.addEventListener("click", function () { + // Disable tombol dan tampilkan spinner + modalButton.disabled = true; + modalButton.innerHTML = ` + + Loading... + `; + const isEdit = saveButton.classList.contains("btn-edit"); + const formData = new FormData(form); + const toast = document.getElementById("toastEditUpdate"); + const toastBody = toast.querySelector(".toast-body"); + const toastHeader = toast.querySelector(".toast-header small"); + + const data = {}; + + // Mengonversi FormData ke dalam JSON + formData.forEach((value, key) => { + data[key] = value; + }); + + const url = form.getAttribute("action"); + + const method = isEdit ? "PUT" : "POST"; + + fetch(url, { + method: method, + body: JSON.stringify(data), + headers: { + Authorization: `Bearer ${document + .querySelector('meta[name="api-token"]') + .getAttribute("content")}`, + "Content-Type": "application/json", + }, + }) + .then((response) => response.json()) + .then((data) => { + if (!data.errors) { + // Remove existing icon (if any) before adding the new one + if (authLogo) { + // Hapus ikon yang sudah ada jika ada + const existingIcon = authLogo.querySelector(".bx"); + if (existingIcon) { + authLogo.removeChild(existingIcon); + } + + // Buat ikon baru + const icon = document.createElement("i"); + icon.classList.add("bx", "bxs-check-square"); + icon.style.fontSize = "25px"; + icon.style.color = "green"; // Pastikan 'green' dalam bentuk string + + // Tambahkan ikon ke dalam auth-logo + authLogo.appendChild(icon); + } + + // Set success message for the toast + toastBody.textContent = isEdit + ? "Data updated successfully!" + : "Data created successfully!"; + toast.classList.add("show"); // Show the toast + setTimeout(() => { + toast.classList.remove("show"); // Hide the toast after 3 seconds + }, 3000); + + setTimeout(() => { + window.location.href = "/data/spatial-plannings"; + }, 3000); + } else { + if (authLogo) { + // Hapus ikon yang sudah ada jika ada + const existingIcon = authLogo.querySelector(".bx"); + if (existingIcon) { + authLogo.removeChild(existingIcon); + } + + // Buat ikon baru + const icon = document.createElement("i"); + icon.classList.add("bx", "bxs-error-alt"); + icon.style.fontSize = "25px"; + icon.style.color = "red"; // Pastikan 'green' dalam bentuk string + + // Tambahkan ikon ke dalam auth-logo + authLogo.appendChild(icon); + } + // Set error message for the toast + toastBody.textContent = + "Error: " + (data.message || "Something went wrong"); + toast.classList.add("show"); // Show the toast + + // Enable button and reset its text on error + modalButton.disabled = false; + modalButton.innerHTML = isEdit ? "Update" : "Create"; + + setTimeout(() => { + toast.classList.remove("show"); // Hide the toast after 3 seconds + }, 3000); + } + }) + .catch((error) => { + if (authLogo) { + // Hapus ikon yang sudah ada jika ada + const existingIcon = authLogo.querySelector(".bx"); + if (existingIcon) { + authLogo.removeChild(existingIcon); + } + + // Buat ikon baru + const icon = document.createElement("i"); + icon.classList.add("bx", "bxs-error-alt"); + icon.style.fontSize = "25px"; + icon.style.color = "red"; // Pastikan 'green' dalam bentuk string + + // Tambahkan ikon ke dalam auth-logo + authLogo.appendChild(icon); + } + // Set error message for the toast + toastBody.textContent = + "An error occurred while processing your request."; + toast.classList.add("show"); // Show the toast + + // Enable button and reset its text on error + modalButton.disabled = false; + modalButton.innerHTML = isEdit ? "Update" : "Create"; + + setTimeout(() => { + toast.classList.remove("show"); // Hide the toast after 3 seconds + }, 3000); + }); + }); + + // Fungsi fetchOptions untuk autocomplete server-side + window.fetchOptions = function (field) { + let inputValue = document.getElementById(field).value; + if (inputValue.length < 2) return; + let districtValue = document.getElementById("district_name").value; // Ambil kecamatan terpilih + + let url = `${ + GlobalConfig.apiHost + }/api/combobox/search-options?query=${encodeURIComponent( + inputValue + )}&field=${field}`; + + // Jika field desa, tambahkan kecamatan sebagai filter + if (field === "village_name") { + url += `&district=${encodeURIComponent(districtValue)}`; + } + + fetch(url, { + method: "GET", + headers: { + Authorization: `Bearer ${document + .querySelector('meta[name="api-token"]') + .getAttribute("content")}`, + "Content-Type": "application/json", + }, + }) + .then((response) => response.json()) + .then((data) => { + let dataList = document.getElementById(field + "Options"); + dataList.innerHTML = ""; + + data.forEach((item) => { + let option = document.createElement("option"); + option.value = item.name; + option.dataset.code = item.code; + dataList.appendChild(option); + }); + }) + .catch((error) => console.error("Error fetching options:", error)); + }; + + document.querySelector(".btn-back").addEventListener("click", function () { + window.history.back(); + }); +}); diff --git a/resources/js/data/spatialPlannings/form-upload.js b/resources/js/data/spatialPlannings/form-upload.js new file mode 100644 index 0000000..4383f54 --- /dev/null +++ b/resources/js/data/spatialPlannings/form-upload.js @@ -0,0 +1,150 @@ +import { Dropzone } from "dropzone"; +import GlobalConfig from "../../global-config.js"; + +Dropzone.autoDiscover = false; + +var previewTemplate, + dropzone, + dropzonePreviewNode = document.querySelector("#dropzone-preview-list"); +console.log(previewTemplate); +console.log(dropzone); +console.log(dropzonePreviewNode); + +(dropzonePreviewNode.id = ""), + dropzonePreviewNode && + ((previewTemplate = dropzonePreviewNode.parentNode.innerHTML), + dropzonePreviewNode.parentNode.removeChild(dropzonePreviewNode), + (dropzone = new Dropzone(".dropzone", { + url: `${GlobalConfig.apiHost}/api/spatial-plannings/import`, + // url: "https://httpbin.org/post", + method: "post", + acceptedFiles: ".xls,.xlsx", // Use acceptedFiles for better validation + previewTemplate: previewTemplate, + previewsContainer: "#dropzone-preview", + autoProcessQueue: false, // Disable auto post + headers: { + Authorization: `Bearer ${document + .querySelector('meta[name="api-token"]') + .getAttribute("content")}` + }, + init: function() { + // Listen for the success event + this.on("success", function(file, response) { + console.log("File successfully uploaded:", file); + console.log("API Response:", response); + + // Show success toast + showToast('bxs-check-square', 'green', response.message); + document.getElementById("submit-upload").innerHTML = "Upload Files"; + // Tunggu sebentar lalu reload halaman + setTimeout(() => { + window.location.href = "/data/spatial-plannings"; + }, 2000); + }); + // Listen for the error event + this.on("error", function(file, errorMessage) { + console.error("Error uploading file:", file); + console.error("Error message:", errorMessage); + // Handle the error response + + // Show error toast + showToast('bxs-error-alt', 'red', errorMessage.message); + document.getElementById("submit-upload").innerHTML = "Upload Files"; + }); + } + }))); + +// Add event listener to control the submission manually +document.querySelector("#submit-upload").addEventListener("click", function() { + console.log("Ini adalah value dropzone", dropzone.files[0]); + const formData = new FormData() + console.log("Dropzonefiles",dropzone.files); + + this.innerHTML = 'Loading...'; + + // Pastikan ada file dalam queue sebelum memprosesnya + if (dropzone.files.length > 0) { + formData.append('file', dropzone.files[0]) + console.log("ini adalah form data on submit", ...formData); + dropzone.processQueue(); // Ini akan manual memicu upload + } else { + // Show error toast when no file is selected + showToast('bxs-error-alt', 'red', "Please add a file first."); + document.getElementById("submit-upload").innerHTML = "Upload Files"; + } +}); + +// Optional: Listen for the 'addedfile' event to log or control file add behavior +dropzone.on("addedfile", function (file) { + console.log("File ditambahkan:", file); + console.log("Nama File:", file.name); + console.log("Tipe File:", file.type); + console.log("Ukuran File:", (file.size / 1024).toFixed(2) + " KB"); +}); + +dropzone.on("complete", function(file) { + dropzone.removeFile(file); +}); + +// Add event listener to download file template +document.getElementById('downloadtempspatialPlannings').addEventListener('click', function() { + var url = `${GlobalConfig.apiHost}/api/download-template-spatialPlannings`; + fetch(url, { + method: 'GET', + headers: { + Authorization: `Bearer ${document + .querySelector('meta[name="api-token"]') + .getAttribute("content")}` + }, + }) + .then(response => { + if (response.ok) { + return response.blob(); // Jika respons OK, konversi menjadi blob + } else { + return response.json(); // Jika respons gagal, konversi menjadi JSON untuk menangani pesan error + } + }) + .then((blob) => { + console.log(blob); + const url = window.URL.createObjectURL(blob); + const a = document.createElement('a'); + a.style.display = 'none'; + a.href = url; + a.download = 'template_rencana_tata_ruang.xlsx'; + document.body.appendChild(a); + a.click(); + window.URL.revokeObjectURL(url); + }) + .catch((error) => { + console.error("Gagal mendownload file:", error); + showToast('bxs-error-alt', 'red', "Template file is not already exist."); + }) +}) + +// Function to show toast +function showToast(iconClass, iconColor, message) { + const toastElement = document.getElementById('toastUploadSpatialPlannings'); + const toastBody = toastElement.querySelector('.toast-body'); + const toastHeader = toastElement.querySelector('.toast-header'); + + // Remove existing icon (if any) before adding the new one + const existingIcon = toastHeader.querySelector('.bx'); + if (existingIcon) { + toastHeader.querySelector('.auth-logo').removeChild(existingIcon); // Remove the existing icon + } + + // Add the new icon to the toast header + const icon = document.createElement('i'); + icon.classList.add('bx', iconClass); + icon.style.fontSize = '25px'; + icon.style.color = iconColor; + toastHeader.querySelector('.auth-logo').appendChild(icon); + + // Set the toast message + toastBody.textContent = message; + + // Show the toast + const toast = new bootstrap.Toast(toastElement); // Inisialisasi Bootstrap Toast + toast.show(); +} + diff --git a/resources/js/data/tourisms/data-tourisms.js b/resources/js/data/tourisms/data-tourisms.js index 0b54a3a..b3473b8 100644 --- a/resources/js/data/tourisms/data-tourisms.js +++ b/resources/js/data/tourisms/data-tourisms.js @@ -5,6 +5,7 @@ import GlobalConfig from "../../global-config.js"; import GeneralTable from "../../table-generator.js"; const dataTourismsColumns = [ + "No", "Nama Perusahaan", "Nama Proyek", "Alamat Usaha", @@ -54,6 +55,7 @@ document.addEventListener("DOMContentLoaded", () => { table.processData = function (data) { return data.data.map((item) => { return [ + item.no, item.business_name, item.project_name, item.business_address, diff --git a/resources/js/data/tourisms/form-create-update.js b/resources/js/data/tourisms/form-create-update.js index eb25d90..c3d6971 100644 --- a/resources/js/data/tourisms/form-create-update.js +++ b/resources/js/data/tourisms/form-create-update.js @@ -28,12 +28,7 @@ document.addEventListener("DOMContentLoaded", function () { data[key] = value; }); - // Log semua data dalam FormData - for (let pair of formData.entries()) { - console.log(pair[0] + ": " + pair[1]); - } const url = form.getAttribute("action"); - console.log("Ini adalah url dari form action", url); const method = isEdit ? "PUT" : "POST"; @@ -49,7 +44,6 @@ document.addEventListener("DOMContentLoaded", function () { }) .then((response) => response.json()) .then((data) => { - console.log("Response data:", data); if (!data.errors) { // Remove existing icon (if any) before adding the new one if (authLogo) { @@ -113,7 +107,6 @@ document.addEventListener("DOMContentLoaded", function () { } }) .catch((error) => { - console.error("Error:", error); if (authLogo) { // Hapus ikon yang sudah ada jika ada const existingIcon = authLogo.querySelector(".bx"); @@ -148,7 +141,6 @@ document.addEventListener("DOMContentLoaded", function () { // Fungsi fetchOptions untuk autocomplete server-side window.fetchOptions = function (field) { let inputValue = document.getElementById(field).value; - console.log("Query Value:", inputValue); // Debugging log if (inputValue.length < 2) return; let districtValue = document.getElementById("district_name").value; // Ambil kecamatan terpilih diff --git a/resources/js/data/tourisms/form-upload.js b/resources/js/data/tourisms/form-upload.js index 4bb1383..aab1366 100644 --- a/resources/js/data/tourisms/form-upload.js +++ b/resources/js/data/tourisms/form-upload.js @@ -88,7 +88,7 @@ dropzone.on("complete", function(file) { // Add event listener to download file template document.getElementById('downloadtemptourisms').addEventListener('click', function() { - var url = `${GlobalConfig.apiHost}/api/download-template-umkm`; + var url = `${GlobalConfig.apiHost}/api/download-template-tourism`; fetch(url, { method: 'GET', headers: { @@ -105,11 +105,12 @@ document.getElementById('downloadtemptourisms').addEventListener('click', functi } }) .then((blob) => { + console.log(blob); const url = window.URL.createObjectURL(blob); const a = document.createElement('a'); a.style.display = 'none'; a.href = url; - a.download = 'template_tourisms.xlsx'; + a.download = 'template_pariwisata.xlsx'; document.body.appendChild(a); a.click(); window.URL.revokeObjectURL(url); @@ -122,7 +123,7 @@ document.getElementById('downloadtemptourisms').addEventListener('click', functi // Function to show toast function showToast(iconClass, iconColor, message) { - const toastElement = document.getElementById('toastUploadUmkm'); + const toastElement = document.getElementById('toastUploadTourisms'); const toastBody = toastElement.querySelector('.toast-body'); const toastHeader = toastElement.querySelector('.toast-header'); diff --git a/resources/js/data/umkm/data-umkm.js b/resources/js/data/umkm/data-umkm.js index 47bf872..c0d9e5a 100644 --- a/resources/js/data/umkm/data-umkm.js +++ b/resources/js/data/umkm/data-umkm.js @@ -4,6 +4,7 @@ import GlobalConfig from "../../global-config.js"; import GeneralTable from "../../table-generator.js"; const dataUMKMColumns = [ + "No", "Nama Usaha", "Alamat Usaha", "Deskripsi Usaha", @@ -54,6 +55,7 @@ document.addEventListener("DOMContentLoaded", () => { table.processData = function (data) { return data.data.map((item) => { return [ + item.no, item.business_name, item.business_address, item.business_desc, diff --git a/resources/js/data/umkm/form-create-update.js b/resources/js/data/umkm/form-create-update.js index 1e93639..d0ebd52 100644 --- a/resources/js/data/umkm/form-create-update.js +++ b/resources/js/data/umkm/form-create-update.js @@ -28,12 +28,7 @@ document.addEventListener("DOMContentLoaded", function () { data[key] = value; }); - // Log semua data dalam FormData - for (let pair of formData.entries()) { - console.log(pair[0] + ": " + pair[1]); - } const url = form.getAttribute("action"); - console.log("Ini adalah url dari form action", url); const method = isEdit ? "PUT" : "POST"; @@ -74,11 +69,11 @@ document.addEventListener("DOMContentLoaded", function () { toast.classList.add('show'); // Show the toast setTimeout(() => { toast.classList.remove('show'); // Hide the toast after 3 seconds - }, 3000); + }, 2000); setTimeout(() => { window.location.href = '/data/umkm'; - }, 3000); + }, 1000); } else { if (authLogo) { // Hapus ikon yang sudah ada jika ada @@ -96,14 +91,16 @@ document.addEventListener("DOMContentLoaded", function () { // Tambahkan ikon ke dalam auth-logo authLogo.appendChild(icon); } - // Set error message for the toast - toastBody.textContent = "Error: " + (data.message || "Something went wrong"); - toast.classList.add('show'); // Show the toast // Enable button and reset its text on error modalButton.disabled = false; modalButton.innerHTML = isEdit ? "Update" : "Create"; + + // Set error message for the toast + toastBody.textContent = "Error: " + (data.message || "Something went wrong"); + toast.classList.add('show'); // Show the toast + setTimeout(() => { toast.classList.remove('show'); // Hide the toast after 3 seconds }, 3000); @@ -127,14 +124,15 @@ document.addEventListener("DOMContentLoaded", function () { // Tambahkan ikon ke dalam auth-logo authLogo.appendChild(icon); } - // Set error message for the toast - toastBody.textContent = "An error occurred while processing your request."; - toast.classList.add('show'); // Show the toast // Enable button and reset its text on error modalButton.disabled = false; modalButton.innerHTML = isEdit ? "Update" : "Create"; + // Set error message for the toast + toastBody.textContent = "An error occurred while processing your request."; + toast.classList.add('show'); // Show the toast + setTimeout(() => { toast.classList.remove('show'); // Hide the toast after 3 seconds }, 3000); @@ -144,7 +142,6 @@ document.addEventListener("DOMContentLoaded", function () { // Fungsi fetchOptions untuk autocomplete server-side window.fetchOptions = function (field) { let inputValue = document.getElementById(field).value; - console.log("Query Value:", inputValue); // Debugging log if (inputValue.length < 2) return; let districtValue = document.getElementById("district_name").value; // Ambil kecamatan terpilih diff --git a/resources/laravel-code-generator/templates/default/api-controller-base-class.stub b/resources/laravel-code-generator/templates/default/api-controller-base-class.stub deleted file mode 100644 index 5cdad7a..0000000 --- a/resources/laravel-code-generator/templates/default/api-controller-base-class.stub +++ /dev/null @@ -1,15 +0,0 @@ -successResponse( - [% model_was_deleted %], - $this->transform($[% model_name_singular_variable %]) - ); \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/api-controller-call-index-api-resource.stub b/resources/laravel-code-generator/templates/default/api-controller-call-index-api-resource.stub deleted file mode 100644 index 9d01d03..0000000 --- a/resources/laravel-code-generator/templates/default/api-controller-call-index-api-resource.stub +++ /dev/null @@ -1 +0,0 @@ -return new [% api_resource_collection_class %]($[% model_name_plural_variable %], [% models_were_retrieved %]); \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/api-controller-call-index-success-method.stub b/resources/laravel-code-generator/templates/default/api-controller-call-index-success-method.stub deleted file mode 100644 index 1ac32cd..0000000 --- a/resources/laravel-code-generator/templates/default/api-controller-call-index-success-method.stub +++ /dev/null @@ -1,26 +0,0 @@ -$[% data_variable %] = $[% model_name_plural_variable %]->transform(function ($[% model_name_singular_variable %]) { - return $this->transform($[% model_name_singular_variable %]); - }); - - return $this->successResponse( - [% models_were_retrieved %], - $[% data_variable %], - [ - 'links' => [ - 'first' => $[% model_name_plural_variable %]->url(1), - 'last' => $[% model_name_plural_variable %]->url($[% model_name_plural_variable %]->lastPage()), - 'prev' => $[% model_name_plural_variable %]->previousPageUrl(), - 'next' => $[% model_name_plural_variable %]->nextPageUrl(), - ], - 'meta' => - [ - 'current_page' => $[% model_name_plural_variable %]->currentPage(), - 'from' => $[% model_name_plural_variable %]->firstItem(), - 'last_page' => $[% model_name_plural_variable %]->lastPage(), - 'path' => $[% model_name_plural_variable %]->resolveCurrentPath(), - 'per_page' => $[% model_name_plural_variable %]->perPage(), - 'to' => $[% model_name_plural_variable %]->lastItem(), - 'total' => $[% model_name_plural_variable %]->total(), - ], - ] - ); \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/api-controller-call-show-api-resource.stub b/resources/laravel-code-generator/templates/default/api-controller-call-show-api-resource.stub deleted file mode 100644 index c9c453d..0000000 --- a/resources/laravel-code-generator/templates/default/api-controller-call-show-api-resource.stub +++ /dev/null @@ -1 +0,0 @@ -return new [% api_resource_class %]($[% model_name_singular_variable %], [% model_was_retrieved %]); \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/api-controller-call-show-success-method.stub b/resources/laravel-code-generator/templates/default/api-controller-call-show-success-method.stub deleted file mode 100644 index c35ff81..0000000 --- a/resources/laravel-code-generator/templates/default/api-controller-call-show-success-method.stub +++ /dev/null @@ -1,4 +0,0 @@ -return $this->successResponse( - [% model_was_retrieved %], - $this->transform($[% model_name_singular_variable %]) - ); \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/api-controller-call-store-api-resource.stub b/resources/laravel-code-generator/templates/default/api-controller-call-store-api-resource.stub deleted file mode 100644 index 48c1110..0000000 --- a/resources/laravel-code-generator/templates/default/api-controller-call-store-api-resource.stub +++ /dev/null @@ -1 +0,0 @@ -return new [% api_resource_class %]($[% model_name_singular_variable %], [% model_was_added %]); \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/api-controller-call-store-success-method.stub b/resources/laravel-code-generator/templates/default/api-controller-call-store-success-method.stub deleted file mode 100644 index e03ecd1..0000000 --- a/resources/laravel-code-generator/templates/default/api-controller-call-store-success-method.stub +++ /dev/null @@ -1,4 +0,0 @@ -return $this->successResponse( - [% model_was_added %], - $this->transform($[% model_name_singular_variable %]) - ); \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/api-controller-call-update-api-resource.stub b/resources/laravel-code-generator/templates/default/api-controller-call-update-api-resource.stub deleted file mode 100644 index ba91ac7..0000000 --- a/resources/laravel-code-generator/templates/default/api-controller-call-update-api-resource.stub +++ /dev/null @@ -1 +0,0 @@ -return new [% api_resource_class %]($[% model_name_singular_variable %], [% model_was_updated %]); \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/api-controller-call-update-success-method.stub b/resources/laravel-code-generator/templates/default/api-controller-call-update-success-method.stub deleted file mode 100644 index 5ea663a..0000000 --- a/resources/laravel-code-generator/templates/default/api-controller-call-update-success-method.stub +++ /dev/null @@ -1,4 +0,0 @@ -return $this->successResponse( - [% model_was_updated %], - $this->transform($[% model_name_singular_variable %]) - ); \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/api-controller-error-response-method.stub b/resources/laravel-code-generator/templates/default/api-controller-error-response-method.stub deleted file mode 100644 index 8b8879e..0000000 --- a/resources/laravel-code-generator/templates/default/api-controller-error-response-method.stub +++ /dev/null @@ -1,14 +0,0 @@ - /** - * Get an error response - * - * @param mix $message - * - * @return Illuminate\Http\Response - */ - protected function errorResponse($message) - { - return response()->json([ - 'errors' => (array) $message, - 'success' => false, - ], 422); - } diff --git a/resources/laravel-code-generator/templates/default/api-controller-get-validator.stub b/resources/laravel-code-generator/templates/default/api-controller-get-validator.stub deleted file mode 100644 index 4414601..0000000 --- a/resources/laravel-code-generator/templates/default/api-controller-get-validator.stub +++ /dev/null @@ -1,16 +0,0 @@ - - /** - * Gets a new validator instance with the defined rules. - * - * @param [% request_fullname %] $request - * - * @return Illuminate\Support\Facades\Validator - */ - protected function getValidator(Request $request) - { - $rules = [ -[% validation_rules %] - ]; -[% file_validation_snippet %] - return Validator::make($request->all(), $rules); - } diff --git a/resources/laravel-code-generator/templates/default/api-controller-success-response-method.stub b/resources/laravel-code-generator/templates/default/api-controller-success-response-method.stub deleted file mode 100644 index d8609e4..0000000 --- a/resources/laravel-code-generator/templates/default/api-controller-success-response-method.stub +++ /dev/null @@ -1,18 +0,0 @@ - /** - * Get a success response - * - * @param mix $message - * @param mix $data - * @param array $meta - * - * @return Illuminate\Http\Response - */ - protected function successResponse($message, $data, array $meta = []) - { - return response()->json( - array_merge([ - 'data' => $data, - 'message' => $message, - 'success' => true, - ], $meta), 200); - } \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/api-controller-transform-method.stub b/resources/laravel-code-generator/templates/default/api-controller-transform-method.stub deleted file mode 100644 index 950f975..0000000 --- a/resources/laravel-code-generator/templates/default/api-controller-transform-method.stub +++ /dev/null @@ -1,13 +0,0 @@ - /** - * Transform the giving [% model_name %] to public friendly array - * - * @param [% use_full_model_name %] $[% model_name_singular_variable %] - * - * @return array - */ - protected function [% transform_method_name %]([% model_name_class %] $[% model_name_singular_variable %]) - { - return [ -[% model_api_array %] - ]; - } diff --git a/resources/laravel-code-generator/templates/default/api-controller-validate.stub b/resources/laravel-code-generator/templates/default/api-controller-validate.stub deleted file mode 100644 index c582ea6..0000000 --- a/resources/laravel-code-generator/templates/default/api-controller-validate.stub +++ /dev/null @@ -1,5 +0,0 @@ -$validator = $this->getValidator($request); - - if ($validator->fails()) { - return $this->errorResponse($validator->errors()->all()); - } diff --git a/resources/laravel-code-generator/templates/default/api-controller.stub b/resources/laravel-code-generator/templates/default/api-controller.stub deleted file mode 100644 index ad86836..0000000 --- a/resources/laravel-code-generator/templates/default/api-controller.stub +++ /dev/null @@ -1,104 +0,0 @@ -errorResponse([% unexpected_error %]); - } - } - - /** - * Display the specified [% model_name %]. - * - * @param int $id - * - * @return Illuminate\Http\Response - */ - public function show($id) - { - $[% model_name_singular_variable %] = [% model_name_class %]::[% with_relations_for_show %]findOrFail($id); - - [% show_return_success %] - } - - /** - * Update the specified [% model_name %] in the storage. - * - * @param int $id - * @param [% request_fullname %] [% request_variable %] - * - * @return Illuminate\Http\Response - */ - public function update($id, [% type_hinted_request_name %]) - { - try { - [% validator_request %] - $[% data_variable %] = [% call_get_data %]; - [% on_update_setter %] - $[% model_name_singular_variable %] = [% model_name_class %]::findOrFail($id); - $[% model_name_singular_variable %]->update($[% data_variable %]); - - [% update_return_success %] - } catch (Exception $exception) { - return $this->errorResponse([% unexpected_error %]); - } - } - - /** - * Remove the specified [% model_name %] from the storage. - * - * @param int $id - * - * @return Illuminate\Http\Response - */ - public function destroy($id) - { - try { - $[% model_name_singular_variable %] = [% model_name_class %]::findOrFail($id); - $[% model_name_singular_variable %]->delete(); - - [% destroy_return_success %] - } catch (Exception $exception) { - return $this->errorResponse([% unexpected_error %]); - } - } -[% get_validator_method %] -[% get_data_method %] -[% upload_method %] -[% transform_method %] -[% response_methods %] -} diff --git a/resources/laravel-code-generator/templates/default/api-documentation-controller-version-based.stub b/resources/laravel-code-generator/templates/default/api-documentation-controller-version-based.stub deleted file mode 100644 index d7c8117..0000000 --- a/resources/laravel-code-generator/templates/default/api-documentation-controller-version-based.stub +++ /dev/null @@ -1,21 +0,0 @@ -getVersion($version)); - - return view($viewName); - } -} diff --git a/resources/laravel-code-generator/templates/default/api-documentation-controller.stub b/resources/laravel-code-generator/templates/default/api-documentation-controller.stub deleted file mode 100644 index 1b27cfe..0000000 --- a/resources/laravel-code-generator/templates/default/api-documentation-controller.stub +++ /dev/null @@ -1,20 +0,0 @@ -[% required_title %] \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/api-documentation-index-authentication.stub b/resources/laravel-code-generator/templates/default/api-documentation-index-authentication.stub deleted file mode 100644 index eb6a978..0000000 --- a/resources/laravel-code-generator/templates/default/api-documentation-index-authentication.stub +++ /dev/null @@ -1,11 +0,0 @@ - - Authorization - [% string_title %] - - [% header_title %] - - [% access_token_with_bearer %] - @if(isset($showValidation) && $showValidation) - - @endif - diff --git a/resources/laravel-code-generator/templates/default/api-documentation-index-failed-authentication.stub b/resources/laravel-code-generator/templates/default/api-documentation-index-failed-authentication.stub deleted file mode 100644 index e412621..0000000 --- a/resources/laravel-code-generator/templates/default/api-documentation-index-failed-authentication.stub +++ /dev/null @@ -1,16 +0,0 @@ -

401 - Unauthorized

-

[% the_user_does_not_have_permission_to_access_the_requested_resource %]

- - - - - - - - - - - - - -
success[% boolean_title %][% indicate_whether_the_request_was_successful_or_not %]
error[% array_of_strings %][% the_error_message %]
diff --git a/resources/laravel-code-generator/templates/default/api-documentation-index-failed-to-retrieve.stub b/resources/laravel-code-generator/templates/default/api-documentation-index-failed-to-retrieve.stub deleted file mode 100644 index d94ce7a..0000000 --- a/resources/laravel-code-generator/templates/default/api-documentation-index-failed-to-retrieve.stub +++ /dev/null @@ -1,16 +0,0 @@ -

202 - Accepted

-

[% the_requested_model_does_not_exists %]

- - - - - - - - - - - - - -
success[% boolean_title %][% indicate_whether_the_request_was_successful_or_not %]
error[% array_of_strings %][% the_error_message %]
diff --git a/resources/laravel-code-generator/templates/default/api-documentation-index-failed-validation.stub b/resources/laravel-code-generator/templates/default/api-documentation-index-failed-validation.stub deleted file mode 100644 index 06c98b6..0000000 --- a/resources/laravel-code-generator/templates/default/api-documentation-index-failed-validation.stub +++ /dev/null @@ -1,16 +0,0 @@ -

422 - Unprocessable Entity

-

[% the_request_failed_validation %]

- - - - - - - - - - - - - -
success[% boolean_title %][% indicate_whether_the_request_was_successful_or_not %]
errors[% array_of_strings %][% list_of_the_invalid_errors %]
diff --git a/resources/laravel-code-generator/templates/default/api-documentation-index-fields-list-body-row-for-model.stub b/resources/laravel-code-generator/templates/default/api-documentation-index-fields-list-body-row-for-model.stub deleted file mode 100644 index 125a36d..0000000 --- a/resources/laravel-code-generator/templates/default/api-documentation-index-fields-list-body-row-for-model.stub +++ /dev/null @@ -1,5 +0,0 @@ - - [% field_name %] - [% field_type_title %] - [% api_field_description %] - diff --git a/resources/laravel-code-generator/templates/default/api-documentation-index-fields-list-body-row.stub b/resources/laravel-code-generator/templates/default/api-documentation-index-fields-list-body-row.stub deleted file mode 100644 index 21c2c77..0000000 --- a/resources/laravel-code-generator/templates/default/api-documentation-index-fields-list-body-row.stub +++ /dev/null @@ -1,12 +0,0 @@ - - [% field_name %] - [% field_type_title %] - [% body_title %] - [% api_field_description %] - @if($showValidation) - - [% validation_rule_required %] - [% validation_rules %] - - @endif - diff --git a/resources/laravel-code-generator/templates/default/api-documentation-index-fields-list.stub b/resources/laravel-code-generator/templates/default/api-documentation-index-fields-list.stub deleted file mode 100644 index c7c5429..0000000 --- a/resources/laravel-code-generator/templates/default/api-documentation-index-fields-list.stub +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - @if($showValidation) - - @endif - - - - [% include_parameter_for_authorized_request %] - @if(isset($withPathId) && $withPathId) - - - - - - @if($showValidation) - - @endif - - - @endif - - [% fields_list_for_body %] - - - -
[% parameter_name_title %][% data_type_title %][% parameter_type_title %][% description_title %][% validation_title %]
[% model_name %][% primary_key_type_title %][% path_title %][% the_id_of_the_model %] - [% validation_rule_required %] -
diff --git a/resources/laravel-code-generator/templates/default/api-documentation-index-request.stub b/resources/laravel-code-generator/templates/default/api-documentation-index-request.stub deleted file mode 100644 index bd1278a..0000000 --- a/resources/laravel-code-generator/templates/default/api-documentation-index-request.stub +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - [% include_parameter_for_authorized_request %] - - -
[% parameter_name_title %][% data_type_title %][% parameter_type_title %][% description_title %]
diff --git a/resources/laravel-code-generator/templates/default/api-documentation-index-retrieved-fields-body-row.stub b/resources/laravel-code-generator/templates/default/api-documentation-index-retrieved-fields-body-row.stub deleted file mode 100644 index 125a36d..0000000 --- a/resources/laravel-code-generator/templates/default/api-documentation-index-retrieved-fields-body-row.stub +++ /dev/null @@ -1,5 +0,0 @@ - - [% field_name %] - [% field_type_title %] - [% api_field_description %] - diff --git a/resources/laravel-code-generator/templates/default/api-documentation-index-retrieved-fields.stub b/resources/laravel-code-generator/templates/default/api-documentation-index-retrieved-fields.stub deleted file mode 100644 index 0c93577..0000000 --- a/resources/laravel-code-generator/templates/default/api-documentation-index-retrieved-fields.stub +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - -[% fields_list_for_body %] - -
[% name_title %][% type_title %][% description_title %]
diff --git a/resources/laravel-code-generator/templates/default/api-documentation-index-retrieved.stub b/resources/laravel-code-generator/templates/default/api-documentation-index-retrieved.stub deleted file mode 100644 index 2c8cd87..0000000 --- a/resources/laravel-code-generator/templates/default/api-documentation-index-retrieved.stub +++ /dev/null @@ -1,21 +0,0 @@ -

200 - Ok

-

[% request_was_successful %]

- - - - - - - - - - - - - - - - - - -
success[% boolean_title %][% indicate_whether_the_request_was_successful_or_not %]
message[% string_title %][% the_success_message %]
data[% array_title %][% the_key_is_the_model_property_and_the_value_is_the_model_value %]
diff --git a/resources/laravel-code-generator/templates/default/api-documentation-index.stub b/resources/laravel-code-generator/templates/default/api-documentation-index.stub deleted file mode 100644 index 2816e9f..0000000 --- a/resources/laravel-code-generator/templates/default/api-documentation-index.stub +++ /dev/null @@ -1,386 +0,0 @@ -@extends('[% layout_name %]') - -@section('content') - -

[% model_plural %]

-[% general_description %] -
- -

[% available_resources %]

-
- -
-
- GET - /{{ Route::getRoutes()->getByName('[% index_route_name %]')->uri() }} -

[% index_route_description %]

-
-
- -
-
- -
-

[% request_title %]

- [% authorized_request_for_index %] - -
-

[% response_title %]

- -

[% index_route_response_description %]

-

- -

200 - Ok

-

[% request_was_successful %]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
success[% boolean_title %]Was the request successful or not.
message[% string_title %][% the_success_message %]
data[% array_title %] - [% the_key_is_the_model_property_and_the_value_is_the_model_value %] -
links[% array_title %] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[% key_title %][% data_type_title %][% description_title %]
first[% string_title %][% link_to_retrieve_first_page %]
last[% string_title %][% link_to_retrieve_last_page %]
prev[% string_title %][% link_to_retrieve_previous_page %]
next[% string_title %][% link_to_retrieve_next_page %]
- -
meta[% array_title %] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[% key_title %][% data_type_title %][% description_title %]
current_page[% integer_title %][% the_number_of_current_page %]
from[% integer_title %][% the_index_of_the_first_retrieved_item %]
last_page[% integer_title %][% the_number_of_the_last_page %]
Path[% string_title %][% the_base_link_to_the_resource %]
per_page[% integer_title %][% the_number_of_models_per_page %]
to[% integer_title %][% the_index_of_the_last_retrieved_item %]
total[% integer_title %][% the_total_of_available_pages %]
- -
- - [% include_failed_authentication_for_authorized_request %] - -
-
- - -
- -
-
- POST - /{{ Route::getRoutes()->getByName('[% store_route_name %]')->uri() }} -

[% store_route_description %]

-
-
- -
-
- -
-

[% request_title %]

- - @include('[% path_to_view_home %]fields-list', [ - 'withValidation' => true - ]) - -
-

[% response_title %]

-

[% store_route_response_description %]

-

- - @include('[% path_to_view_home %]retrieved') - @include('[% path_to_view_home %]failed-to-retrieve') - @include('[% path_to_view_home %]failed-validation') - [% include_failed_authentication_for_authorized_request %] - -
-
- - - -
- -
-
- POST - /{{ Route::getRoutes()->getByName('[% update_route_name %]')->uri() }} -

[% update_route_description %]

-
-
- -
-
- -
-
- -

[% request_title %]

- - @include('[% path_to_view_home %]fields-list', [ - 'withValidation' => true, - 'withPathId' => true, - ]) - -
-

[% response_title %]

-

[% update_route_response_description %]

-

- - @include('[% path_to_view_home %]retrieved') - @include('[% path_to_view_home %]failed-to-retrieve') - @include('[% path_to_view_home %]failed-validation') - [% include_failed_authentication_for_authorized_request %] - -
-
-
- - - -
- -
-
- GET - /{{ Route::getRoutes()->getByName('[% show_route_name %]')->uri() }} -

[% show_route_description %]

-
-
- -
-
- -
- -

[% request_title %]

- - - - - - - - - - - - [% include_parameter_for_authorized_request %] - - - - - - - -
[% parameter_name_title %][% data_type_title %][% parameter_type_title %][% description_title %]
[% model_name %][% integer_title %][% path_title %][% the_id_of_model_to_retrieve %]
- - -
-

[% response_title %]

-

[% show_route_response_description %]

-

- - @include('[% path_to_view_home %]retrieved') - @include('[% path_to_view_home %]failed-to-retrieve') - [% include_failed_authentication_for_authorized_request %] - -
-
- - -
- -
-
- DELETE - /{{ Route::getRoutes()->getByName('[% destroy_route_name %]')->uri() }} -

[% destroy_route_description %]

-
-
- -
-
- -
- -

[% request_title %]

- - - - - - - - - - - - [% include_parameter_for_authorized_request %] - - - - - - - -
[% parameter_name_title %][% data_type_title %][% parameter_type_title %][% description_title %]
[% model_name %][% integer_title %][% path_title %][% the_id_of_model_to_delete %]
- - -
-

[% response_title %]

-

[% destroy_route_response_description %]

-

- - @include('[% path_to_view_home %]retrieved') - @include('[% path_to_view_home %]failed-to-retrieve') - [% include_failed_authentication_for_authorized_request %] - -
- -
- -
- -

[% model_definition_title %]

-
- -
-
- [% model_name_title %] -
-
- -
-
- -
- - - - - - - - - - [% fields_list_for_body %] - -
[% field_name_title %][% field_type_title %][% description_title %]
-
-
- -@endsection diff --git a/resources/laravel-code-generator/templates/default/api-documentation-routes-8.stub b/resources/laravel-code-generator/templates/default/api-documentation-routes-8.stub deleted file mode 100644 index 1e3291f..0000000 --- a/resources/laravel-code-generator/templates/default/api-documentation-routes-8.stub +++ /dev/null @@ -1,2 +0,0 @@ -Route::get('[% prefix %][% version %]', [[% controller_name %]::class, 'index']) - ->name('[% index_route_name %]'); diff --git a/resources/laravel-code-generator/templates/default/api-documentation-routes.stub b/resources/laravel-code-generator/templates/default/api-documentation-routes.stub deleted file mode 100644 index d74d23f..0000000 --- a/resources/laravel-code-generator/templates/default/api-documentation-routes.stub +++ /dev/null @@ -1,2 +0,0 @@ -Route::get('[% prefix %][% version %]', '[% controller_name %]@index') - ->name('[% index_route_name %]'); diff --git a/resources/laravel-code-generator/templates/default/api-documentation-version-based-base-controller.stub b/resources/laravel-code-generator/templates/default/api-documentation-version-based-base-controller.stub deleted file mode 100644 index 9f4201d..0000000 --- a/resources/laravel-code-generator/templates/default/api-documentation-version-based-base-controller.stub +++ /dev/null @@ -1,38 +0,0 @@ -versions)) { - return $version; - } - - return end($this->versions); - } -} \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/api-resource-collection.stub b/resources/laravel-code-generator/templates/default/api-resource-collection.stub deleted file mode 100644 index f6f8578..0000000 --- a/resources/laravel-code-generator/templates/default/api-resource-collection.stub +++ /dev/null @@ -1,50 +0,0 @@ -message = $message; - } - - /** - * Transform the resource collection into an array. - * - * @param \Illuminate\Http\Request - * @return array - */ - public function toArray($request) - { - return [ - 'data' => $this->collection->transform(function ($[% model_name_singular_variable %]) { - return $this->transformModel($[% model_name_singular_variable %]); - }), - 'message' => $this->message, - 'success' => true, - ]; - } - -[% transform_method %] -} diff --git a/resources/laravel-code-generator/templates/default/api-resource.stub b/resources/laravel-code-generator/templates/default/api-resource.stub deleted file mode 100644 index addba74..0000000 --- a/resources/laravel-code-generator/templates/default/api-resource.stub +++ /dev/null @@ -1,59 +0,0 @@ -message = $message; - } - - /** - * Transform the resource into an array. - * - * @param \Illuminate\Http\Request $request - * - * @return array - */ - public function toArray($request) - { - return [ -[% model_api_array %] - ]; - } - - /** - * Get any additional data that should be returned with the resource array. - * - * @param \Illuminate\Http\Request $request - * - * @return array - */ - public function with($request) - { - return [ - 'success' => true, - 'message' => $this->message, - ]; - } -} diff --git a/resources/laravel-code-generator/templates/default/api-routes-8.stub b/resources/laravel-code-generator/templates/default/api-routes-8.stub deleted file mode 100644 index 28e3886..0000000 --- a/resources/laravel-code-generator/templates/default/api-routes-8.stub +++ /dev/null @@ -1,10 +0,0 @@ - Route::get('/', [[% controller_name %]::class, 'index']) - ->name('[% index_route_name %]'); - Route::get('/show/{[% model_name_singular_variable %]}',[[% controller_name %]::class, 'show']) - ->name('[% show_route_name %]')[% route_id_clause %]; - Route::post('/', [[% controller_name %]::class, 'store']) - ->name('[% store_route_name %]'); - Route::put('[% model_name_snake %]/{[% model_name_singular_variable %]}', [[% controller_name %]::class, 'update']) - ->name('[% update_route_name %]')[% route_id_clause %]; - Route::delete('/[% model_name_snake %]/{[% model_name_singular_variable %]}',[[% controller_name %]::class, 'destroy']) - ->name('[% destroy_route_name %]')[% route_id_clause %]; \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/api-routes.stub b/resources/laravel-code-generator/templates/default/api-routes.stub deleted file mode 100644 index bd4043d..0000000 --- a/resources/laravel-code-generator/templates/default/api-routes.stub +++ /dev/null @@ -1,10 +0,0 @@ - Route::get('/', '[% controller_name %]@index') - ->name('[% index_route_name %]'); - Route::get('/show/{[% model_name_singular_variable %]}','[% controller_name %]@show') - ->name('[% show_route_name %]')[% route_id_clause %]; - Route::post('/', '[% controller_name %]@store') - ->name('[% store_route_name %]'); - Route::put('[% model_name_snake %]/{[% model_name_singular_variable %]}', '[% controller_name %]@update') - ->name('[% update_route_name %]')[% route_id_clause %]; - Route::delete('/[% model_name_snake %]/{[% model_name_singular_variable %]}','[% controller_name %]@destroy') - ->name('[% destroy_route_name %]')[% route_id_clause %]; \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/controller-affirm-method.stub b/resources/laravel-code-generator/templates/default/controller-affirm-method.stub deleted file mode 100644 index 7d4f94f..0000000 --- a/resources/laravel-code-generator/templates/default/controller-affirm-method.stub +++ /dev/null @@ -1,17 +0,0 @@ - - /** - * Validate the given request with the defined rules. - * - * @param [% request_fullname %] $request - * - * @return boolean - */ - protected function affirm(Request $request) - { - $rules = [ -[% validation_rules %] - ]; -[% file_validation_snippet %] - - return $this->validate($request, $rules); - } diff --git a/resources/laravel-code-generator/templates/default/controller-constructor.stub b/resources/laravel-code-generator/templates/default/controller-constructor.stub deleted file mode 100644 index a670bb3..0000000 --- a/resources/laravel-code-generator/templates/default/controller-constructor.stub +++ /dev/null @@ -1,10 +0,0 @@ - /** - * Create a new controller instance. - * - * @return void - */ - public function __construct() - { - [% auth_middleware %] - } - \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/controller-getdata-method-5.5.stub b/resources/laravel-code-generator/templates/default/controller-getdata-method-5.5.stub deleted file mode 100644 index 3295ab8..0000000 --- a/resources/laravel-code-generator/templates/default/controller-getdata-method-5.5.stub +++ /dev/null @@ -1,21 +0,0 @@ - - /** - * Get the request's data from the request. - * - * [% request_name_comment %] - * @return array - */ - [% visibility_level %] function getData([% type_hinted_request_name %]) - { - $rules = [ - [% validation_rules %] - ]; - - [% file_validation_snippet %] - $data = [% request_variable %]->validate($rules); - -[% file_snippet %] -[% boolean_snippet %] -[% string_to_null_snippet %] - return $data; - } \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/controller-getdata-method.stub b/resources/laravel-code-generator/templates/default/controller-getdata-method.stub deleted file mode 100644 index f35cf67..0000000 --- a/resources/laravel-code-generator/templates/default/controller-getdata-method.stub +++ /dev/null @@ -1,15 +0,0 @@ - - /** - * Get the request's data from the request. - * - * [% request_name_comment %] - * @return array - */ - [% visibility_level %] function getData([% type_hinted_request_name %]) - { - $data = [% request_variable %]->only([% fillable %]); -[% file_snippet %] -[% boolean_snippet %] -[% string_to_null_snippet %] - return $data; - } \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/controller-upload-method-5.3.stub b/resources/laravel-code-generator/templates/default/controller-upload-method-5.3.stub deleted file mode 100644 index 45b9a51..0000000 --- a/resources/laravel-code-generator/templates/default/controller-upload-method-5.3.stub +++ /dev/null @@ -1,19 +0,0 @@ - - /** - * Moves the attached file to the server. - * - * @param \Symfony\Component\HttpFoundation\File\UploadedFile $file - * - * @return string - */ - protected function moveFile($file) - { - if (!$file->isValid()) { - return ''; - } - - $path = config('laravel-code-generator.files_upload_path', 'uploads'); - $saved = $file->store('public/' . $path, config('filesystems.default')); - - return substr($saved, 7); - } diff --git a/resources/laravel-code-generator/templates/default/controller-upload-method.stub b/resources/laravel-code-generator/templates/default/controller-upload-method.stub deleted file mode 100644 index 3354a45..0000000 --- a/resources/laravel-code-generator/templates/default/controller-upload-method.stub +++ /dev/null @@ -1,20 +0,0 @@ - - /** - * Moves the attached file to the server. - * - * @param \Symfony\Component\HttpFoundation\File\UploadedFile $file - * - * @return string - */ - protected function moveFile($file) - { - if (!$file->isValid()) { - return ''; - } - - $fileName = sprintf('%s.%s', uniqid(), $file->getClientOriginalExtension()); - $destinationPath = config('laravel-code-generator.files_upload_path','uploads'); - $path = $file->move($destinationPath, $fileName); - - return $destinationPath . '/' . $fileName; - } \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/controller.stub b/resources/laravel-code-generator/templates/default/controller.stub deleted file mode 100644 index fbd784e..0000000 --- a/resources/laravel-code-generator/templates/default/controller.stub +++ /dev/null @@ -1,126 +0,0 @@ -route('[% index_route_name %]') - ->with('success_message', [% model_was_added %]); - } - - /** - * Display the specified [% model_name %]. - * - * @param int $id - * - * @return \Illuminate\View\View - */ - public function show($id) - { - $[% model_name_singular_variable %] = [% model_name_class %]::[% with_relations_for_show %]findOrFail($id); - - return view('[% show_view_name %]'[% view_variables_for_show %]); - } - - /** - * Show the form for editing the specified [% model_name %]. - * - * @param int $id - * - * @return \Illuminate\View\View - */ - public function edit($id) - { - $[% model_name_singular_variable %] = [% model_name_class %]::findOrFail($id); - [% relation_collections %] - - return view('[% edit_view_name %]'[% view_variables_for_edit %]); - } - - /** - * Update the specified [% model_name %] in the storage. - * - * @param int $id - * @param [% request_fullname %] [% request_variable %] - * - * @return \Illuminate\Http\RedirectResponse | \Illuminate\Routing\Redirector - */ - public function update($id, [% type_hinted_request_name %]) - { - [% call_affirm %] - $[% data_variable %] = [% call_get_data %]; - [% on_update_setter %] - $[% model_name_singular_variable %] = [% model_name_class %]::findOrFail($id); - $[% model_name_singular_variable %]->update($[% data_variable %]); - - return redirect()->route('[% index_route_name %]') - ->with('success_message', [% model_was_updated %]); - } - - /** - * Remove the specified [% model_name %] from the storage. - * - * @param int $id - * - * @return \Illuminate\Http\RedirectResponse | \Illuminate\Routing\Redirector - */ - public function destroy($id) - { - try { - $[% model_name_singular_variable %] = [% model_name_class %]::findOrFail($id); - $[% model_name_singular_variable %]->delete(); - - return redirect()->route('[% index_route_name %]') - ->with('success_message', [% model_was_deleted %]); - } catch (Exception $exception) { - - return back()->withInput() - ->withErrors(['unexpected_error' => [% unexpected_error %]]); - } - } -[% affirm_method %] -[% get_data_method %] -[% upload_method %] -} diff --git a/resources/laravel-code-generator/templates/default/create.blade.stub b/resources/laravel-code-generator/templates/default/create.blade.stub deleted file mode 100644 index ac5dfc4..0000000 --- a/resources/laravel-code-generator/templates/default/create.blade.stub +++ /dev/null @@ -1,46 +0,0 @@ -@extends('[% layout_name %]') - -@section('content') - -
- -
-

[% create_model %]

-
- - - -
-
- - -
- - @if ($errors->any()) - - @endif - -
- {{ csrf_field() }} - @include ('[% form_view_name %]', [ - '[% model_name_singular_variable %]' => null, - ]) - -
- -
- -
- -
-
- -@endsection - - diff --git a/resources/laravel-code-generator/templates/default/edit.blade.stub b/resources/laravel-code-generator/templates/default/edit.blade.stub deleted file mode 100644 index 081642d..0000000 --- a/resources/laravel-code-generator/templates/default/edit.blade.stub +++ /dev/null @@ -1,47 +0,0 @@ -@extends('[% layout_name %]') - -@section('content') - -
- -
-

{{ !empty([% model_header %]) ? [% model_header %] : '[% model_name_title %]' }}

-
- - - - - - - -
-
- -
- - @if ($errors->any()) - - @endif - -
- {{ csrf_field() }} - - @include ('[% form_view_name %]', [ - '[% model_name_singular_variable %]' => $[% model_name_singular_variable %], - ]) - -
- -
-
- -
-
- -@endsection \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/form-file-field.blade.stub b/resources/laravel-code-generator/templates/default/form-file-field.blade.stub deleted file mode 100644 index 06fe6cf..0000000 --- a/resources/laravel-code-generator/templates/default/form-file-field.blade.stub +++ /dev/null @@ -1,14 +0,0 @@ -
- -
- - @if (isset($[% model_name_singular_variable %]->[% field_name %]) && !empty($[% model_name_singular_variable %]->[% field_name %])) - -
-
- -
- -
- - @endif diff --git a/resources/laravel-code-generator/templates/default/form-helper-field.blade.stub b/resources/laravel-code-generator/templates/default/form-helper-field.blade.stub deleted file mode 100644 index d34652f..0000000 --- a/resources/laravel-code-generator/templates/default/form-helper-field.blade.stub +++ /dev/null @@ -1 +0,0 @@ - {!! $errors->first('[% field_name %]', '
:message
') !!} \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/form-input-field.blade.stub b/resources/laravel-code-generator/templates/default/form-input-field.blade.stub deleted file mode 100644 index fd62a05..0000000 --- a/resources/laravel-code-generator/templates/default/form-input-field.blade.stub +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/form-input-wrapper.blade.stub b/resources/laravel-code-generator/templates/default/form-input-wrapper.blade.stub deleted file mode 100644 index ac7c9cf..0000000 --- a/resources/laravel-code-generator/templates/default/form-input-wrapper.blade.stub +++ /dev/null @@ -1,8 +0,0 @@ - -
-[% field_label %] -
-[% field_input %] -[% field_validation_helper %] -
-
diff --git a/resources/laravel-code-generator/templates/default/form-label-field.blade.stub b/resources/laravel-code-generator/templates/default/form-label-field.blade.stub deleted file mode 100644 index b48e5f3..0000000 --- a/resources/laravel-code-generator/templates/default/form-label-field.blade.stub +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/form-month-field.blade.stub b/resources/laravel-code-generator/templates/default/form-month-field.blade.stub deleted file mode 100644 index 8ba00e6..0000000 --- a/resources/laravel-code-generator/templates/default/form-month-field.blade.stub +++ /dev/null @@ -1,8 +0,0 @@ - diff --git a/resources/laravel-code-generator/templates/default/form-nolabel-field.blade.stub b/resources/laravel-code-generator/templates/default/form-nolabel-field.blade.stub deleted file mode 100644 index e1ad396..0000000 --- a/resources/laravel-code-generator/templates/default/form-nolabel-field.blade.stub +++ /dev/null @@ -1 +0,0 @@ -
\ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/form-password-field.blade.stub b/resources/laravel-code-generator/templates/default/form-password-field.blade.stub deleted file mode 100644 index 6f87c4e..0000000 --- a/resources/laravel-code-generator/templates/default/form-password-field.blade.stub +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/form-pickitems-field.blade.stub b/resources/laravel-code-generator/templates/default/form-pickitems-field.blade.stub deleted file mode 100644 index e8c4fc2..0000000 --- a/resources/laravel-code-generator/templates/default/form-pickitems-field.blade.stub +++ /dev/null @@ -1,6 +0,0 @@ -
- - -
diff --git a/resources/laravel-code-generator/templates/default/form-pickitems-inline-field.blade.stub b/resources/laravel-code-generator/templates/default/form-pickitems-inline-field.blade.stub deleted file mode 100644 index 08568c6..0000000 --- a/resources/laravel-code-generator/templates/default/form-pickitems-inline-field.blade.stub +++ /dev/null @@ -1,6 +0,0 @@ -
- - -
diff --git a/resources/laravel-code-generator/templates/default/form-request.stub b/resources/laravel-code-generator/templates/default/form-request.stub deleted file mode 100644 index 22ecfd7..0000000 --- a/resources/laravel-code-generator/templates/default/form-request.stub +++ /dev/null @@ -1,35 +0,0 @@ -has('[% field_name %]') ? ' is-invalid' : '' }}[% css_class %]" id="[% field_name %]" name="[% field_name %]"[% field_multiple %][% required_field %]> - [% placeholder %] - @foreach ([% field_items %] as $key => [% field_item %]) - - @endforeach - - \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/form-selectrange-field.blade.stub b/resources/laravel-code-generator/templates/default/form-selectrange-field.blade.stub deleted file mode 100644 index c35ab34..0000000 --- a/resources/laravel-code-generator/templates/default/form-selectrange-field.blade.stub +++ /dev/null @@ -1,9 +0,0 @@ - - \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/form-textarea-field.blade.stub b/resources/laravel-code-generator/templates/default/form-textarea-field.blade.stub deleted file mode 100644 index 1f1d3e5..0000000 --- a/resources/laravel-code-generator/templates/default/form-textarea-field.blade.stub +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/form.blade.stub b/resources/laravel-code-generator/templates/default/form.blade.stub deleted file mode 100644 index ad6d762..0000000 --- a/resources/laravel-code-generator/templates/default/form.blade.stub +++ /dev/null @@ -1 +0,0 @@ -[% form_fields_html %] diff --git a/resources/laravel-code-generator/templates/default/index.blade.stub b/resources/laravel-code-generator/templates/default/index.blade.stub deleted file mode 100644 index 7eae1a6..0000000 --- a/resources/laravel-code-generator/templates/default/index.blade.stub +++ /dev/null @@ -1,78 +0,0 @@ -@extends('[% layout_name %]') - -@section('content') - - @if(Session::has('success_message')) - - @endif - -
- -
-

[% model_name_plural_title %]

-
- - - -
-
- - @if(count($[% model_name_plural_variable %]) == 0) -
-

[% no_models_available %]

-
- @else -
-
- - - - -[% header_cells %] - - - - - @foreach($[% model_name_plural_variable %] as $[% model_name_singular_variable %]) - -[% body_cells %] - - - @endforeach - -
- -
- - {{ csrf_field() }} - -
- - - - - - - - -
- -
- -
- -
- - {!! $[% model_name_plural_variable %]->links('[% pagination_view_name %]') !!} -
- - @endif - -
-@endsection \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/index.body.cell.blade.stub b/resources/laravel-code-generator/templates/default/index.body.cell.blade.stub deleted file mode 100644 index 99bdccb..0000000 --- a/resources/laravel-code-generator/templates/default/index.body.cell.blade.stub +++ /dev/null @@ -1 +0,0 @@ - {{ [% field_value %] }} \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/index.header.cell.blade.stub b/resources/laravel-code-generator/templates/default/index.header.cell.blade.stub deleted file mode 100644 index 8ca0b94..0000000 --- a/resources/laravel-code-generator/templates/default/index.header.cell.blade.stub +++ /dev/null @@ -1 +0,0 @@ - [% field_title %] \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/language.stub b/resources/laravel-code-generator/templates/default/language.stub deleted file mode 100644 index 4a711de..0000000 --- a/resources/laravel-code-generator/templates/default/language.stub +++ /dev/null @@ -1,5 +0,0 @@ - - - - - - - {{ config('app.name', '[% application_name %]') }} - - - - {{-- --}} - - - - - -
- @yield('content') -
- - - {{-- --}} - - diff --git a/resources/laravel-code-generator/templates/default/login-partial.stub b/resources/laravel-code-generator/templates/default/login-partial.stub deleted file mode 100644 index 86f73df..0000000 --- a/resources/laravel-code-generator/templates/default/login-partial.stub +++ /dev/null @@ -1,10 +0,0 @@ -@if (Route::has('login')) - -@endif \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/migration-schema-down.stub b/resources/laravel-code-generator/templates/default/migration-schema-down.stub deleted file mode 100644 index 22fa175..0000000 --- a/resources/laravel-code-generator/templates/default/migration-schema-down.stub +++ /dev/null @@ -1 +0,0 @@ -Schema::[% connection_name %]drop('[% table_name %]'); \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/migration-schema-up.stub b/resources/laravel-code-generator/templates/default/migration-schema-up.stub deleted file mode 100644 index 871cdc3..0000000 --- a/resources/laravel-code-generator/templates/default/migration-schema-up.stub +++ /dev/null @@ -1,4 +0,0 @@ -Schema::[% connection_name %][% operation_name %]('[% table_name %]', function(Blueprint $table) - { -[% blue_print_body %] - }); \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/migration.stub b/resources/laravel-code-generator/templates/default/migration.stub deleted file mode 100644 index 43bfce1..0000000 --- a/resources/laravel-code-generator/templates/default/migration.stub +++ /dev/null @@ -1,27 +0,0 @@ -getDateFormat(), $value)->format('[% date_format %]'); \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/model-accessor-multiple-answers.stub b/resources/laravel-code-generator/templates/default/model-accessor-multiple-answers.stub deleted file mode 100644 index bb17361..0000000 --- a/resources/laravel-code-generator/templates/default/model-accessor-multiple-answers.stub +++ /dev/null @@ -1 +0,0 @@ -return json_decode($value) ?: []; \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/model-accessor.stub b/resources/laravel-code-generator/templates/default/model-accessor.stub deleted file mode 100644 index cd9c029..0000000 --- a/resources/laravel-code-generator/templates/default/model-accessor.stub +++ /dev/null @@ -1,10 +0,0 @@ - /** - * Get [% field_name %] in array format - * - * @param string $value - * @return array - */ - public function get[% field_name_cap %]Attribute($value) - { - [% content %] - } diff --git a/resources/laravel-code-generator/templates/default/model-mutator-datetime.stub b/resources/laravel-code-generator/templates/default/model-mutator-datetime.stub deleted file mode 100644 index 538687d..0000000 --- a/resources/laravel-code-generator/templates/default/model-mutator-datetime.stub +++ /dev/null @@ -1 +0,0 @@ -$this->attributes['[% field_name %]'] = !empty($value) ? \DateTime::createFromFormat('[% date_format %]', $value) : null; \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/model-mutator-multiple-answers.stub b/resources/laravel-code-generator/templates/default/model-mutator-multiple-answers.stub deleted file mode 100644 index 0da4880..0000000 --- a/resources/laravel-code-generator/templates/default/model-mutator-multiple-answers.stub +++ /dev/null @@ -1 +0,0 @@ -$this->attributes['[% field_name %]'] = json_encode($value); \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/model-mutator.stub b/resources/laravel-code-generator/templates/default/model-mutator.stub deleted file mode 100644 index fc8eae0..0000000 --- a/resources/laravel-code-generator/templates/default/model-mutator.stub +++ /dev/null @@ -1,10 +0,0 @@ - /** - * Set the [% field_name %]. - * - * @param string $value - * @return void - */ - public function set[% field_name_cap %]Attribute($value) - { - [% content %] - } diff --git a/resources/laravel-code-generator/templates/default/model-primary-key.stub b/resources/laravel-code-generator/templates/default/model-primary-key.stub deleted file mode 100644 index 925b8ea..0000000 --- a/resources/laravel-code-generator/templates/default/model-primary-key.stub +++ /dev/null @@ -1,6 +0,0 @@ - /** - * The database primary key value. - * - * @var string - */ - protected $primaryKey = '[% primary_key %]'; \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/model-relation.stub b/resources/laravel-code-generator/templates/default/model-relation.stub deleted file mode 100644 index 0ce8050..0000000 --- a/resources/laravel-code-generator/templates/default/model-relation.stub +++ /dev/null @@ -1,9 +0,0 @@ - /** - * Get the [% relation_name %] for this model. - * - * @return [% relation_return_type %] - */ - public function [% relation_name %]() - { - return $this->[% relation_type %]([% relation_params %]); - } diff --git a/resources/laravel-code-generator/templates/default/model-timestamps.stub b/resources/laravel-code-generator/templates/default/model-timestamps.stub deleted file mode 100644 index ca00793..0000000 --- a/resources/laravel-code-generator/templates/default/model-timestamps.stub +++ /dev/null @@ -1,6 +0,0 @@ - /** - * Indicates if the model should be timestamped. - * - * @var bool - */ - public $timestamps = false; \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/model.stub b/resources/laravel-code-generator/templates/default/model.stub deleted file mode 100644 index a80befd..0000000 --- a/resources/laravel-code-generator/templates/default/model.stub +++ /dev/null @@ -1,44 +0,0 @@ -hasPages()) - -@endif diff --git a/resources/laravel-code-generator/templates/default/routes-8.stub b/resources/laravel-code-generator/templates/default/routes-8.stub deleted file mode 100644 index fb8be75..0000000 --- a/resources/laravel-code-generator/templates/default/routes-8.stub +++ /dev/null @@ -1,14 +0,0 @@ - Route::get('/', [[% controller_name %]::class, 'index']) - ->name('[% index_route_name %]'); - Route::get('/create', [[% controller_name %]::class, 'create']) - ->name('[% create_route_name %]'); - Route::get('/show/{[% model_name_singular_variable %]}',[[% controller_name %]::class, 'show']) - ->name('[% show_route_name %]')[% route_id_clause %]; - Route::get('/{[% model_name_singular_variable %]}/edit',[[% controller_name %]::class, 'edit']) - ->name('[% edit_route_name %]')[% route_id_clause %]; - Route::post('/', [[% controller_name %]::class, 'store']) - ->name('[% store_route_name %]'); - Route::put('[% model_name_snake %]/{[% model_name_singular_variable %]}', [[% controller_name %]::class, 'update']) - ->name('[% update_route_name %]')[% route_id_clause %]; - Route::delete('/[% model_name_snake %]/{[% model_name_singular_variable %]}',[[% controller_name %]::class, 'destroy']) - ->name('[% destroy_route_name %]')[% route_id_clause %]; \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/routes-group.stub b/resources/laravel-code-generator/templates/default/routes-group.stub deleted file mode 100644 index 23a1f20..0000000 --- a/resources/laravel-code-generator/templates/default/routes-group.stub +++ /dev/null @@ -1,6 +0,0 @@ - -Route::group([ - [% prefix %] -], function () { -[% routes %] -}); diff --git a/resources/laravel-code-generator/templates/default/routes.stub b/resources/laravel-code-generator/templates/default/routes.stub deleted file mode 100644 index 615d786..0000000 --- a/resources/laravel-code-generator/templates/default/routes.stub +++ /dev/null @@ -1,14 +0,0 @@ - Route::get('/', '[% controller_name %]@index') - ->name('[% index_route_name %]'); - Route::get('/create','[% controller_name %]@create') - ->name('[% create_route_name %]'); - Route::get('/show/{[% model_name_singular_variable %]}','[% controller_name %]@show') - ->name('[% show_route_name %]')[% route_id_clause %]; - Route::get('/{[% model_name_singular_variable %]}/edit','[% controller_name %]@edit') - ->name('[% edit_route_name %]')[% route_id_clause %]; - Route::post('/', '[% controller_name %]@store') - ->name('[% store_route_name %]'); - Route::put('[% model_name_snake %]/{[% model_name_singular_variable %]}', '[% controller_name %]@update') - ->name('[% update_route_name %]')[% route_id_clause %]; - Route::delete('/[% model_name_snake %]/{[% model_name_singular_variable %]}','[% controller_name %]@destroy') - ->name('[% destroy_route_name %]')[% route_id_clause %]; \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/show.blade.stub b/resources/laravel-code-generator/templates/default/show.blade.stub deleted file mode 100644 index 047f2af..0000000 --- a/resources/laravel-code-generator/templates/default/show.blade.stub +++ /dev/null @@ -1,42 +0,0 @@ -@extends('[% layout_name %]') - -@section('content') - -
- -
-

{{ isset([% model_header %]) ? [% model_header %] : '[% model_name_title %]' }}

-
-
- - {{ csrf_field() }} - - - - - - - - - - - - - - - -
-
-
- -
-
-[% table_rows %] -
- -
-
- -@endsection \ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/show.row.blade.stub b/resources/laravel-code-generator/templates/default/show.row.blade.stub deleted file mode 100644 index 1d714e6..0000000 --- a/resources/laravel-code-generator/templates/default/show.row.blade.stub +++ /dev/null @@ -1,2 +0,0 @@ -
[% field_title %]
-
{{ [% field_value %] }}
\ No newline at end of file diff --git a/resources/laravel-code-generator/templates/default/view-model.stub b/resources/laravel-code-generator/templates/default/view-model.stub deleted file mode 100644 index d861db4..0000000 --- a/resources/laravel-code-generator/templates/default/view-model.stub +++ /dev/null @@ -1,30 +0,0 @@ - 'Data']) + +@section('content') + +@include('layouts.partials/page-title', ['title' => 'Data', 'subtitle' => 'PDAM']) + + +
+
+
+
+ Back +
+
+
+ @csrf + @include('customers.form') + +
+
+
+
+
+ +@endsection + +@section('scripts') +@vite(['resources/js/customers/create.js']) +@endsection diff --git a/resources/views/customers/edit.blade.php b/resources/views/customers/edit.blade.php new file mode 100644 index 0000000..1cff9ae --- /dev/null +++ b/resources/views/customers/edit.blade.php @@ -0,0 +1,33 @@ +@extends('layouts.vertical', ['subtitle' => 'Data']) + +@section('content') + +@include('layouts.partials/page-title', ['title' => 'Data', 'subtitle' => 'PDAM']) + + +
+
+
+
+ Back +
+
+
+ @csrf + @method('put') + @include('customers.form') + +
+
+
+
+
+ +@endsection + +@section('scripts') +@vite(['resources/js/customers/edit.js']) +@endsection diff --git a/resources/views/customers/form.blade.php b/resources/views/customers/form.blade.php new file mode 100644 index 0000000..c08f165 --- /dev/null +++ b/resources/views/customers/form.blade.php @@ -0,0 +1,24 @@ +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
\ No newline at end of file diff --git a/resources/views/customers/index.blade.php b/resources/views/customers/index.blade.php new file mode 100644 index 0000000..bab6ebf --- /dev/null +++ b/resources/views/customers/index.blade.php @@ -0,0 +1,31 @@ +@extends('layouts.vertical', ['subtitle' => 'Data']) + +@section('css') +@vite(['node_modules/gridjs/dist/theme/mermaid.min.css']) +@endsection + +@section('content') + +@include('layouts.partials/page-title', ['title' => 'Data', 'subtitle' => 'PDAM']) + + + +
+
+
+
+
+ Create + Upload +
+
+
+
+
+
+ +@endsection + +@section('scripts') +@vite(['resources/js/customers/index.js']) +@endsection \ No newline at end of file diff --git a/resources/views/customers/upload.blade.php b/resources/views/customers/upload.blade.php new file mode 100644 index 0000000..fb56b8c --- /dev/null +++ b/resources/views/customers/upload.blade.php @@ -0,0 +1,80 @@ +@extends('layouts.vertical', ['subtitle' => 'Data']) + +@section('content') + +@include('layouts.partials/page-title', ['title' => 'Data', 'subtitle' => 'Tata Ruang']) + + +
+
+
+
+
Upload Data
+

+ Please upload a file with the extension .xls or .xlsx with a maximum size of 10 MB. +
+ For .xls and .xlsx files, ensure that the data is contained within a single sheet with the following columns: + Nomor Pelanggan, Kota Pelayanan, Nama, Alamat, Latitude, Longitude +

+
+ +
+ +
+ +
+
+
+ +
+
+
+ +

Drop files here or click to upload.

+
+
+ +
    +
  • + +
    +
    +
    +
    + +
    +
    +
    +
    +
      +
    +

    + +
    +
    +
    + +
    +
    +
    +
  • +
+ +
+
+ +
+
+
+
+
+ +@endsection + +@section('scripts') +@vite(['resources/js/customers/upload.js']) +@endsection \ No newline at end of file diff --git a/resources/views/data/spatialPlannings/form-upload.blade.php b/resources/views/data/spatialPlannings/form-upload.blade.php new file mode 100644 index 0000000..4f86296 --- /dev/null +++ b/resources/views/data/spatialPlannings/form-upload.blade.php @@ -0,0 +1,91 @@ +@extends('layouts.vertical', ['subtitle' => 'File Upload']) + +@section('content') + +@include('layouts.partials/page-title', ['title' => 'Form', 'subtitle' => 'File Uploads']) + +
+
+
+
+
+
Upload Data Pariwisata
+ +
+
+ +
+ +
+ +
+
+
+ +
+
+
+ +

Drop files here or click to upload.

+

+ Please upload a file with the extension .xls or .xlsx with a maximum size of 10 MB. +
+

+
+
+ +
    +
  • + +
    +
    +
    +
    + +
    +
    +
    +
    +
      +
    +

    + +
    +
    +
    + +
    +
    +
    +
  • +
+ +
+
+ +
+
+
+
+
+ +
+ +
+ +@endsection + +@section('scripts') +@vite(['resources/js/data/spatialPlannings/form-upload.js']) +@endsection \ No newline at end of file diff --git a/resources/views/data/spatialPlannings/form.blade.php b/resources/views/data/spatialPlannings/form.blade.php new file mode 100644 index 0000000..969bcbe --- /dev/null +++ b/resources/views/data/spatialPlannings/form.blade.php @@ -0,0 +1,130 @@ +@extends('layouts.vertical', ['subtitle' => $subtitle]) + +@section('content') + +@include('layouts.partials/page-title', ['title' => $title, 'subtitle' => $subtitle]) + +
+ @if (session('error')) +
+ {{ session('error') }} +
+ @endif + + @if ($errors->any()) +
+
    + @foreach ($errors->all() as $error) +
  • {{ $error }}
  • + @endforeach +
+
+ @endif + +
+
+
+ +
+
+
+ @csrf + @if(isset($modelInstance)) + @method('PUT') + @endif + +
+ @foreach($fields as $field => $label) +
+ + @php + $fieldType = $fieldTypes[$field] ?? 'text'; // Default text jika tidak ditemukan tipe + @endphp + + @if($fieldType == 'textarea') + + @elseif($fieldType == 'select' && isset($dropdownOptions[$field])) + + @elseif($fieldType == 'combobox' && isset($dropdownOptions[$field])) + + + @elseif($fieldType == 'date') + + @else + + @endif +
+ @endforeach +
+ +
+ +
+
+
+
+
+
+ + + + + +
+ +
+ +@endsection + +@section('scripts') +@vite(['resources/js/data/spatialPlannings/form-create-update.js']) +@endsection \ No newline at end of file diff --git a/resources/views/data/spatialPlannings/index.blade.php b/resources/views/data/spatialPlannings/index.blade.php new file mode 100644 index 0000000..da2e4b0 --- /dev/null +++ b/resources/views/data/spatialPlannings/index.blade.php @@ -0,0 +1,38 @@ +@extends('layouts.vertical', ['subtitle' => 'Rencana Tata Ruang']) + +@section('css') +@vite(['node_modules/gridjs/dist/theme/mermaid.min.css']) +@endsection + +@section('content') +@include('layouts.partials/page-title', ['title' => 'Data', 'subtitle' => 'Rencana Tata Ruang']) + +
+
+
Daftar Rencana Tata Ruang
+
+
+
+
+ + +
+
+
+
+
+
+
+ +{{--
--}} + +@endsection + +@section('scripts') +@vite(['resources/js/data/spatialPlannings/data-spatialPlannings.js']) +@endsection \ No newline at end of file diff --git a/resources/views/data/tourisms/form-upload.blade.php b/resources/views/data/tourisms/form-upload.blade.php index 9f77c02..c8e4acf 100644 --- a/resources/views/data/tourisms/form-upload.blade.php +++ b/resources/views/data/tourisms/form-upload.blade.php @@ -71,7 +71,7 @@
-