diff --git a/app/Http/Controllers/CuranmorController.php b/app/Http/Controllers/CuranmorController.php index 3b3ef22..038ead2 100644 --- a/app/Http/Controllers/CuranmorController.php +++ b/app/Http/Controllers/CuranmorController.php @@ -43,9 +43,9 @@ public function store(Request $request) ]); Curanmor::create($validateData); - return redirect('/curanmor')->with('succes', 'Berhasil Menambahkan Data Curanmor Baru'); + return redirect('/dashboard/curanmor')->with('succes', 'Berhasil Menambahkan Data Curanmor Baru'); }catch (\Exception $e){ - return redirect('/curanmor')->with('error', 'Gagal Menambahkan Data Curanmor Baru'); + return redirect('/dashboard/curanmor')->with('error', 'Gagal Menambahkan Data Curanmor Baru'); } } @@ -107,9 +107,9 @@ public function update(Request $request, Curanmor $curanmor) // simpan hasil ke file json file_put_contents(storage_path('app/public/hasil_kmeans_curanmor.json'), json_encode($hasil)); - return redirect('/curanmor')->with('succes', 'Data Kecamatan Berhasil Diubah'); + return redirect('/dashboard/curanmor')->with('succes', 'Data Kecamatan Berhasil Diubah'); } catch (\Exception $e) { - return redirect('/curanmor')->with('error', 'Data Kecamatan Gagal Diubah: ' . $e->getMessage()); + return redirect('/dashboard/curanmor')->with('error', 'Data Kecamatan Gagal Diubah: ' . $e->getMessage()); } } @@ -124,15 +124,15 @@ public function destroy($curanmor) // Pastikan data ditemukan sebelum menghapus if (!$hapus) { - return redirect('/curanmor')->with('error', 'Data tidak ditemukan.'); + return redirect('/dashboard/curanmor')->with('error', 'Data tidak ditemukan.'); } // Hapus data $hapus->delete(); - return redirect('/curanmor')->with('succes', 'Data Curanmor Berhasil Dihapus'); + return redirect('/dashboard/curanmor')->with('succes', 'Data Curanmor Berhasil Dihapus'); } catch (\Exception $e) { - return redirect('/curanmor')->with('error', 'Terjadi kesalahan: ' . $e->getMessage()); + return redirect('/dashboard/curanmor')->with('error', 'Terjadi kesalahan: ' . $e->getMessage()); } } diff --git a/app/Http/Controllers/CurasController.php b/app/Http/Controllers/CurasController.php index 0f960d4..51c3846 100644 --- a/app/Http/Controllers/CurasController.php +++ b/app/Http/Controllers/CurasController.php @@ -44,9 +44,9 @@ public function store(Request $request) ]); Curas::create($validateData); - return redirect('/curas')->with('succes', 'Berhasil Menambahkan Data Curas Baru'); + return redirect('/dashboard/curas')->with('succes', 'Berhasil Menambahkan Data Curas Baru'); }catch (\Exception $e){ - return redirect('/curas')->with('error', 'Gagal Menambahkan Data Curas Baru'); + return redirect('/dashboard/curas')->with('error', 'Gagal Menambahkan Data Curas Baru'); } } @@ -113,9 +113,9 @@ public function update(Request $request, $id) // simpan hasil ke file json file_put_contents(storage_path('app/public/hasil_kmeans_curas.json'), json_encode($hasil)); - return redirect('/curas')->with('succes', 'Data Kecamatan Berhasil Diubah'); + return redirect('/dashboard/curas')->with('succes', 'Data Kecamatan Berhasil Diubah'); } catch (\Exception $e) { - return redirect('/curas')->with('error', 'Data Kecamatan Gagal Diubah: ' . $e->getMessage()); + return redirect('/dashboard/curas')->with('error', 'Data Kecamatan Gagal Diubah: ' . $e->getMessage()); } } @@ -134,15 +134,15 @@ public function destroy($curas) // Pastikan data ditemukan sebelum menghapus if (!$hapus) { - return redirect('/curas')->with('error', 'Data tidak ditemukan.'); + return redirect('/dashboard/curas')->with('error', 'Data tidak ditemukan.'); } // Hapus data $hapus->delete(); - return redirect('/curas')->with('succes', 'Data Curas Berhasil Dihapus'); + return redirect('/dashboard/curas')->with('succes', 'Data Curas Berhasil Dihapus'); } catch (\Exception $e) { - return redirect('/curas')->with('error', 'Terjadi kesalahan: ' . $e->getMessage()); + return redirect('/dashboard/curas')->with('error', 'Terjadi kesalahan: ' . $e->getMessage()); } } diff --git a/app/Http/Controllers/KecamatanController.php b/app/Http/Controllers/KecamatanController.php index 46399b7..9f11a8f 100644 --- a/app/Http/Controllers/KecamatanController.php +++ b/app/Http/Controllers/KecamatanController.php @@ -36,9 +36,9 @@ public function store(Request $request) ]); Kecamatan::create($validateData); - return redirect('/kecamatan')->with('succes', 'Berhasil Menambahkan Data Kecamatan Baru'); + return redirect('/dashboard/kecamatan')->with('succes', 'Berhasil Menambahkan Data Kecamatan Baru'); }catch (\Exception $e){ - return redirect('/kecamatan')->with('error', 'Gagal Menambahkan Data Kecamatan Baru'); + return redirect('/dashboard/kecamatan')->with('error', 'Gagal Menambahkan Data Kecamatan Baru'); } } @@ -77,9 +77,9 @@ public function update(Request $request, Kecamatan $kecamatan) ]); Kecamatan::where('id', $kecamatan->id)->update($validateData); - return redirect('/kecamatan')->with('succes', 'Data Kecamatan Berhasil Di Ubah'); + return redirect('/dashboard/kecamatan')->with('succes', 'Data Kecamatan Berhasil Di Ubah'); }catch (\Exception $e){ - return redirect('/kecamatan')->with('error', 'Data Kecamatan Gagal Di Ubah'); + return redirect('/dashboard/kecamatan')->with('error', 'Data Kecamatan Gagal Di Ubah'); } @@ -92,10 +92,10 @@ public function destroy(Kecamatan $kecamatan) { try{ Kecamatan::destroy($kecamatan->id); - return redirect('/kecamatan')->with('succes', 'Data Kecamatan Berhasil Di Hapus'); + return redirect('/dashboard/kecamatan')->with('succes', 'Data Kecamatan Berhasil Di Hapus'); }catch (\Exception $e){ - return redirect('/kecamatan')->with('error', 'Data Kecamatan '. $kecamatan->nama_kecamatan .' Gagal Di Hapus | Hapus Data Curas Atau Curanmor Untuk Kecamatan '. $kecamatan->nama_kecamatan.' Terlebih Dahulu'); + return redirect('/dashboard/kecamatan')->with('error', 'Data Kecamatan '. $kecamatan->nama_kecamatan .' Gagal Di Hapus | Hapus Data Curas Atau Curanmor Untuk Kecamatan '. $kecamatan->nama_kecamatan.' Terlebih Dahulu'); } diff --git a/app/Http/Controllers/KlasterController.php b/app/Http/Controllers/KlasterController.php index 1fc461b..0ccd038 100644 --- a/app/Http/Controllers/KlasterController.php +++ b/app/Http/Controllers/KlasterController.php @@ -36,10 +36,10 @@ public function store(Request $request) ]); Klaster::create($validateData); - return redirect('/klaster')->with('succes', 'Berhasil Menambahkan Klaster Baru'); + return redirect('/dashboard/klaster')->with('succes', 'Berhasil Menambahkan Klaster Baru'); }catch (\Exception $e){ - return redirect('/klaster')->with('error', 'Gagal Menambahkan Klaster Baru'); + return redirect('/dashboard/klaster')->with('error', 'Gagal Menambahkan Klaster Baru'); } } @@ -80,9 +80,9 @@ public function update(Request $request, Klaster $klaster) // Hanya update data yang diisi (tidak mengganti dengan null) Klaster::where('id', $klaster->id)->update(array_filter($validateData)); - return redirect('/klaster')->with('success', 'Data Klaster Berhasil Diubah'); + return redirect('/dashboard/klaster')->with('success', 'Data Klaster Berhasil Diubah'); } catch (\Exception $e) { - return redirect('/klaster')->with('error', 'Data Klaster Gagal Diubah'); + return redirect('/dashboard/klaster')->with('error', 'Data Klaster Gagal Diubah'); } } @@ -94,10 +94,10 @@ public function destroy(Klaster $klaster) { try{ Klaster::destroy($klaster->id); - return redirect('/klaster')->with('succes', 'Data Klaster Berhasil Di Hapus'); + return redirect('/dashboard/klaster')->with('succes', 'Data Klaster Berhasil Di Hapus'); }catch (\Exception $e){ - return redirect('/klaster')->with('error', 'Data Klaster '. $klaster->nama_kecamatan .' Gagal Di Hapus | Hapus Data Curas Atau Curanmor Untuk Klaster '. $klaster->nama_kecamatan.' Terlebih Dahulu'); + return redirect('/dashboard/klaster')->with('error', 'Data Klaster '. $klaster->nama_kecamatan .' Gagal Di Hapus | Hapus Data Curas Atau Curanmor Untuk Klaster '. $klaster->nama_kecamatan.' Terlebih Dahulu'); } } -} +} \ No newline at end of file diff --git a/app/Http/Controllers/loginController.php b/app/Http/Controllers/loginController.php new file mode 100644 index 0000000..456630b --- /dev/null +++ b/app/Http/Controllers/loginController.php @@ -0,0 +1,12 @@ +belongsTo(Kecamatan::class, 'kecamatan_id'); } + + protected $with = ['punyaKecamatanCuranmor', 'punyaKlasterCuranmor']; + } diff --git a/app/Models/Curas.php b/app/Models/Curas.php index 5e7eeaa..f35147a 100644 --- a/app/Models/Curas.php +++ b/app/Models/Curas.php @@ -19,9 +19,11 @@ public function punyaKlasterCuras(): BelongsTo{ public function punyaKecamatanCuras(): BelongsTo { - return $this->belongsTo(Kecamatan::class, 'kecamatan_id'); // Pastikan FK benar + return $this->belongsTo(Kecamatan::class, 'kecamatan_id'); } + protected $with = ['punyaKlasterCuras', 'punyaKecamatanCuras']; + } diff --git a/app/View/Components/layoutLanding.php b/app/View/Components/layoutLanding.php new file mode 100644 index 0000000..90d9653 --- /dev/null +++ b/app/View/Components/layoutLanding.php @@ -0,0 +1,26 @@ +float('jumlah_curas'); $table->foreignId('klaster_id')->nullable()->constrained( - table: 'klasters', indexName: 'curas_klaster_id')->onDelete('set null'); + table: 'klasters', indexName: 'curas_klaster_id'); $table->timestamps(); }); } diff --git a/database/migrations/2025_02_20_164712_create_curanmors_table.php b/database/migrations/2025_02_20_164712_create_curanmors_table.php index 6031dca..fc89a17 100644 --- a/database/migrations/2025_02_20_164712_create_curanmors_table.php +++ b/database/migrations/2025_02_20_164712_create_curanmors_table.php @@ -17,7 +17,7 @@ public function up(): void table: 'kecamatans', indexName: 'curanmor_kecamatan_id'); $table->float('jumlah_curanmor'); $table->foreignId('klaster_id')->nullable()->constrained( - table: 'klasters', indexName: 'klaster_kecamata_id')->onDelete('set null');; + table: 'klasters', indexName: 'klaster_kecamatan_id'); $table->timestamps(); }); } diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 53aefdd..4ac8bd0 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -2,9 +2,10 @@ namespace Database\Seeders; -use App\Models\Curas; use App\Models\User; +use App\Models\Curas; // use Illuminate\Database\Console\Seeds\WithoutModelEvents; +use App\Services\KMeansService; use Illuminate\Database\Seeder; class DatabaseSeeder extends Seeder @@ -23,5 +24,13 @@ public function run(): void CurasSeeder::class, CuranmorSeeder::class, ]); + + $serviceKMeansCuras = new KMeansService(); + $hasilKMeansCuras = $serviceKMeansCuras->hitungKMeansCuras(); + file_put_contents(storage_path('app/public/hasil_kmeans_curas.json'), json_encode($hasilKMeansCuras)); + + $serviceKmeansCuranmor = new KMeansService(); + $hasilKMeansCuranmor = $serviceKmeansCuranmor->hitungKMeansCuranmor(); + file_put_contents(storage_path('app/public/hasil_kmeans_curanmor.json'), json_encode($hasilKMeansCuranmor)); } } diff --git a/public/assets/assetLanding/images/login/1.png b/public/assets/assetLanding/images/login/1.png new file mode 100644 index 0000000..b1695bd Binary files /dev/null and b/public/assets/assetLanding/images/login/1.png differ diff --git a/public/assets/assetLanding/images/login/2.png b/public/assets/assetLanding/images/login/2.png new file mode 100644 index 0000000..9f27757 Binary files /dev/null and b/public/assets/assetLanding/images/login/2.png differ diff --git a/public/assets/assetLanding/images/login/3.png b/public/assets/assetLanding/images/login/3.png new file mode 100644 index 0000000..d0a178a Binary files /dev/null and b/public/assets/assetLanding/images/login/3.png differ diff --git a/public/assets/assetLanding/images/login/login.png b/public/assets/assetLanding/images/login/login.png new file mode 100644 index 0000000..8538ccf Binary files /dev/null and b/public/assets/assetLanding/images/login/login.png differ diff --git a/resources/views/Admin/dashboardEditCuranmor.blade.php b/resources/views/Admin/dashboardEditCuranmor.blade.php index 111fb07..079db9d 100644 --- a/resources/views/Admin/dashboardEditCuranmor.blade.php +++ b/resources/views/Admin/dashboardEditCuranmor.blade.php @@ -11,7 +11,7 @@