From 3ff970391c5cc4dde4825c760dfc0e44aa37f19b Mon Sep 17 00:00:00 2001 From: myuqinurrohman Date: Thu, 27 Feb 2025 09:52:49 +0700 Subject: [PATCH] feat: goverment agency --- app/Helpers/CustomHelper.php | 8 +- .../Dashboard/ClassificationController.php | 9 +- .../Dashboard/DatatableController.php | 56 ++++++++++-- .../Dashboard/GovernmentAgencyController.php | 85 +++++++++++++++++++ .../Dashboard/SubClassificationController.php | 9 +- app/Http/Requests/GovernmentAgencyRequest.php | 32 +++++++ app/Models/GovernmentAgency.php | 19 +++++ ...14325_create_government_agencies_table.php | 34 ++++++++ database/seeders/ClassificationSeeder.php | 16 +++- database/seeders/DatabaseSeeder.php | 3 + database/seeders/GovernmentAgencySeeder.php | 24 ++++++ database/seeders/SubClassificationSeeder.php | 18 +++- .../dashboard/classifications/edit.blade.php | 2 +- .../dashboard/classifications/show.blade.php | 2 +- .../government-agencies/create.blade.php | 77 +++++++++++++++++ .../government-agencies/edit.blade.php | 78 +++++++++++++++++ .../government-agencies/index.blade.php | 60 +++++++++++++ .../government-agencies/show.blade.php | 68 +++++++++++++++ .../sub-classifications/create.blade.php | 2 +- .../sub-classifications/edit.blade.php | 4 +- .../sub-classifications/show.blade.php | 2 +- .../views/partials/app/datatable.blade.php | 22 +++++ .../partials/dashboard/sidebar.blade.php | 2 +- routes/web.php | 15 ++++ 24 files changed, 620 insertions(+), 27 deletions(-) create mode 100644 app/Http/Controllers/Dashboard/GovernmentAgencyController.php create mode 100644 app/Http/Requests/GovernmentAgencyRequest.php create mode 100644 app/Models/GovernmentAgency.php create mode 100644 database/migrations/2025_02_27_014325_create_government_agencies_table.php create mode 100644 database/seeders/GovernmentAgencySeeder.php create mode 100644 resources/views/dashboard/government-agencies/create.blade.php create mode 100644 resources/views/dashboard/government-agencies/edit.blade.php create mode 100644 resources/views/dashboard/government-agencies/index.blade.php create mode 100644 resources/views/dashboard/government-agencies/show.blade.php diff --git a/app/Helpers/CustomHelper.php b/app/Helpers/CustomHelper.php index 4ff2c6e..e1265a1 100644 --- a/app/Helpers/CustomHelper.php +++ b/app/Helpers/CustomHelper.php @@ -75,16 +75,16 @@ function is_role($roles) { } } -if (! function_exists('encryptId')) { - function encryptId($id) +if (! function_exists('encrypt_id')) { + function encrypt_id($id) { $hashids = new Hashids('alwayssaybismillahirrahmanirrahim', 15); return $hashids->encode($id); } } -if (! function_exists('decryptId')) { - function decryptId($hash) +if (! function_exists('decrypt_id')) { + function decrypt_id($hash) { $hashids = new Hashids('alwayssaybismillahirrahmanirrahim', 15); $result = $hashids->decode($hash); diff --git a/app/Http/Controllers/Dashboard/ClassificationController.php b/app/Http/Controllers/Dashboard/ClassificationController.php index ea5cf08..6b0434a 100644 --- a/app/Http/Controllers/Dashboard/ClassificationController.php +++ b/app/Http/Controllers/Dashboard/ClassificationController.php @@ -38,7 +38,7 @@ public function store(ClassificationRequest $request){ } public function edit($id){ - $classification = Classification::find(decryptId($id)); + $classification = Classification::find(decrypt_id($id)); return view('dashboard.classifications.edit', [ 'title' => 'Ubah Klasifikasi', @@ -51,7 +51,8 @@ public function update(ClassificationRequest $request, $id){ $validatedData['slug'] = Str::slug($validatedData['name']); $validatedData['enhancer_id'] = Auth::id(); - $updatedClassification = Classification::find(decryptId($id))->update($validatedData); + $classification = Classification::find(decrypt_id($id)); + $updatedClassification = $classification->update($validatedData); if($updatedClassification){ return redirect()->back()->with('success-status', 'Berhasil mengubah klasifikasi.'); @@ -61,7 +62,7 @@ public function update(ClassificationRequest $request, $id){ } public function show($id){ - $classification = Classification::find(decryptId($id)); + $classification = Classification::find(decrypt_id($id)); return view('dashboard.classifications.show', [ 'title' => 'Detail Klasifikasi', @@ -71,7 +72,7 @@ public function show($id){ public function destroy($id){ try { - $classification = Classification::findOrFail(decryptId($id)); + $classification = Classification::findOrFail(decrypt_id($id)); $classification->delete(); diff --git a/app/Http/Controllers/Dashboard/DatatableController.php b/app/Http/Controllers/Dashboard/DatatableController.php index c409a95..77ec068 100644 --- a/app/Http/Controllers/Dashboard/DatatableController.php +++ b/app/Http/Controllers/Dashboard/DatatableController.php @@ -4,6 +4,7 @@ use App\Http\Controllers\Controller; use App\Models\Classification; +use App\Models\GovernmentAgency; use App\Models\SubClassification; use Illuminate\Http\Request; use Illuminate\Support\Facades\Log; @@ -39,13 +40,13 @@ public function classification(Request $request){ }) ->addColumn('action', function ($data) { - $showUrl = route('dashboard.classifications.show', ['id' => encryptId($data->id)]); + $showUrl = route('dashboard.classifications.show', ['id' => encrypt_id($data->id)]); $addSubClassificationUrl = route('dashboard.sub.classifications.create', ['classification' => $data->slug]); - $editUrl = route('dashboard.classifications.edit', ['id' => encryptId($data->id)]); + $editUrl = route('dashboard.classifications.edit', ['id' => encrypt_id($data->id)]); - $deleteUrl = route('dashboard.classifications.destroy', ['id' => encryptId($data->id)]); + $deleteUrl = route('dashboard.classifications.destroy', ['id' => encrypt_id($data->id)]); $dropdown = '