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 = '
@@ -106,11 +107,11 @@ public function subClassification(Request $request){
}
})
->addColumn('action', function ($data) {
- $showUrl = route('dashboard.sub.classifications.show', ['id' => encryptId($data->id)]);
+ $showUrl = route('dashboard.sub.classifications.show', ['id' => encrypt_id($data->id)]);
- $editUrl = route('dashboard.sub.classifications.edit', ['id' => encryptId($data->id)]);
+ $editUrl = route('dashboard.sub.classifications.edit', ['id' => encrypt_id($data->id)]);
- $deleteUrl = route('dashboard.sub.classifications.destroy', ['id' => encryptId($data->id)]);
+ $deleteUrl = route('dashboard.sub.classifications.destroy', ['id' => encrypt_id($data->id)]);
$dropdown = '
@@ -141,4 +142,47 @@ public function subClassification(Request $request){
return response()->json(['error' => 'Unauthorized'], 401);
}
+
+ public function governmentAgency(Request $request){
+ if ($request->ajax()) {
+ $data = GovernmentAgency::all();
+
+ return DataTables::of($data)
+ ->addIndexColumn()
+ ->addColumn('action', function ($data) {
+ $showUrl = route('dashboard.government.agencies.show', ['id' => encrypt_id($data->id)]);
+
+ $editUrl = route('dashboard.government.agencies.edit', ['id' => encrypt_id($data->id)]);
+
+ $deleteUrl = route('dashboard.government.agencies.destroy', ['id' => encrypt_id($data->id)]);
+
+ $dropdown = '
';
+
+ return $dropdown;
+ })
+
+ ->rawColumns(['action'])
+ ->make(true);
+ }
+
+ return response()->json(['error' => 'Unauthorized'], 401);
+
+ }
}
diff --git a/app/Http/Controllers/Dashboard/GovernmentAgencyController.php b/app/Http/Controllers/Dashboard/GovernmentAgencyController.php
new file mode 100644
index 0000000..aeb495a
--- /dev/null
+++ b/app/Http/Controllers/Dashboard/GovernmentAgencyController.php
@@ -0,0 +1,85 @@
+ 'OPD'
+ ]);
+ }
+
+ public function create(){
+ return view('dashboard.government-agencies.create', [
+ 'title' => 'Tambah OPD'
+ ]);
+ }
+
+ public function store(GovernmentAgencyRequest $request){
+ $validatedData = $request->validated();
+ $validatedData['slug'] = Str::slug($validatedData['name']);
+ $validatedData['enhancer_id'] = Auth::id();
+
+ $createdGovernmentAgency = GovernmentAgency::create($validatedData);
+
+ if($createdGovernmentAgency){
+ return redirect()->back()->with('success-status', 'Berhasil menambahkan OPD.');
+ }else{
+ return redirect()->back()->with('failed-status', 'Gagal menambahkan OPD');
+ }
+ }
+
+ public function edit($id){
+ $governmentAgency = GovernmentAgency::find(decrypt_id($id));
+
+ return view('dashboard.government-agencies.edit',[
+ 'title' => 'Ubah OPD',
+ 'governmentAgency' => $governmentAgency
+ ]);
+ }
+
+ public function update(GovernmentAgencyRequest $request, $id){
+ $validatedData = $request->validated();
+ $validatedData['slug'] = Str::slug($validatedData['name']);
+ $validatedData['enhancer_id'] = Auth::id();
+
+ $governmentAgency = GovernmentAgency::findOrFail(decrypt_id($id));
+ $updatedGovernmentAgency = $governmentAgency->update($validatedData);
+
+ if($updatedGovernmentAgency){
+ return redirect()->back()->with('success-status', 'Berhasil mengubah OPD.');
+ }else{
+ return redirect()->back()->with('failed-status', 'Gagal mengubah OPD');
+ }
+
+ }
+
+ public function show($id){
+ $governmentAgency = GovernmentAgency::find(decrypt_id($id));
+
+ return view('dashboard.government-agencies.show',[
+ 'title' => 'Detail OPD',
+ 'governmentAgency' => $governmentAgency
+ ]);
+ }
+
+ public function destroy($id){
+ try {
+ $governmentAgency = GovernmentAgency::findOrFail(decrypt_id($id));
+
+ $governmentAgency->delete();
+
+ return response()->json(['message' => 'Berhasil menghapus OPD']);
+ } catch (\Exception $e) {
+ return response()->json(['message' => 'Gagal menghapus OPD.'], 500);
+ }
+ }
+}
diff --git a/app/Http/Controllers/Dashboard/SubClassificationController.php b/app/Http/Controllers/Dashboard/SubClassificationController.php
index dd3cbf7..06bbce8 100644
--- a/app/Http/Controllers/Dashboard/SubClassificationController.php
+++ b/app/Http/Controllers/Dashboard/SubClassificationController.php
@@ -55,7 +55,7 @@ public function store(SubClassificationRequest $request){
}
public function edit($id){
- $subClassification = SubClassification::find(decryptId($id));
+ $subClassification = SubClassification::find(decrypt_id($id));
return view('dashboard.sub-classifications.edit', [
'title' => 'Ubah Sub Klasifikasi',
@@ -69,7 +69,8 @@ public function update(SubClassificationRequest $request, $id){
$validatedData['slug'] = Str::slug($validatedData['name']);
$validatedData['enhancer_id'] = Auth::id();
- $updatedSubClassification = SubClassification::find(decryptId($id))->update($validatedData);
+ $subClassification = SubClassification::find(decrypt_id($id));
+ $updatedSubClassification = $subClassification->update($validatedData);
if($updatedSubClassification){
return redirect()->back()->with('success-status', 'Berhasil mengubah sub klasifikasi.');
@@ -79,7 +80,7 @@ public function update(SubClassificationRequest $request, $id){
}
public function show($id){
- $subClassification = SubClassification::with(['classification'])->find(decryptId($id));
+ $subClassification = SubClassification::with(['classification'])->find(decrypt_id($id));
return view('dashboard.sub-classifications.show', [
'title' => 'Detail Sub Klasifikasi',
@@ -89,7 +90,7 @@ public function show($id){
public function destroy($id){
try {
- $subClassification = SubClassification::findOrFail(decryptId($id));
+ $subClassification = SubClassification::findOrFail(decrypt_id($id));
$subClassification->delete();
diff --git a/app/Http/Requests/GovernmentAgencyRequest.php b/app/Http/Requests/GovernmentAgencyRequest.php
new file mode 100644
index 0000000..5b17fe6
--- /dev/null
+++ b/app/Http/Requests/GovernmentAgencyRequest.php
@@ -0,0 +1,32 @@
+|string>
+ */
+ public function rules(): array
+ {
+ return [
+ 'name' => ['required', 'max:100'],
+ 'short_name' => ['nullable', 'max:100'],
+ 'location' => ['nullable'],
+ 'description' => ['nullable'],
+ ];
+ }
+}
diff --git a/app/Models/GovernmentAgency.php b/app/Models/GovernmentAgency.php
new file mode 100644
index 0000000..9c56d10
--- /dev/null
+++ b/app/Models/GovernmentAgency.php
@@ -0,0 +1,19 @@
+id();
+ $table->string('name');
+ $table->string('slug');
+ $table->string('short_name')->nullable();
+ $table->text('location')->nullable();
+ $table->text('description')->nullable();
+ $table->unsignedBigInteger('enhancer_id');
+ $table->foreign('enhancer_id')->references('id')->on('users');
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::dropIfExists('government_agencies');
+ }
+};
diff --git a/database/seeders/ClassificationSeeder.php b/database/seeders/ClassificationSeeder.php
index 09bd9d3..9e5dffc 100644
--- a/database/seeders/ClassificationSeeder.php
+++ b/database/seeders/ClassificationSeeder.php
@@ -2,6 +2,7 @@
namespace Database\Seeders;
+use App\Models\Classification;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
@@ -12,6 +13,19 @@ class ClassificationSeeder extends Seeder
*/
public function run(): void
{
- //
+ Classification::insert([
+ [
+ 'name' => 'Politik',
+ 'slug' => 'politik',
+ 'description' => null,
+ 'enhancer_id' => '1'
+ ],
+ [
+ 'name' => 'Kiriminal',
+ 'slug' => 'kriminal',
+ 'description' => null,
+ 'enhancer_id' => '1'
+ ]
+ ]);
}
}
diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php
index 93d4a2c..ff5ce76 100644
--- a/database/seeders/DatabaseSeeder.php
+++ b/database/seeders/DatabaseSeeder.php
@@ -15,5 +15,8 @@ public function run(): void
{
$this->call(RoleSeeder::class);
$this->call(UserSeeder::class);
+ $this->call(ClassificationSeeder::class);
+ $this->call(SubClassificationSeeder::class);
+ $this->call(GovernmentAgencySeeder::class);
}
}
diff --git a/database/seeders/GovernmentAgencySeeder.php b/database/seeders/GovernmentAgencySeeder.php
new file mode 100644
index 0000000..59b58eb
--- /dev/null
+++ b/database/seeders/GovernmentAgencySeeder.php
@@ -0,0 +1,24 @@
+ 'Dinas Pendidikan',
+ 'slug' => 'dinas-pendidikan',
+ 'short_name' => 'Disdik',
+ 'description' => 'Dinas yang menangani bidang pendidikan.',
+ 'enhancer_id' => '1',
+ ]);
+ }
+}
diff --git a/database/seeders/SubClassificationSeeder.php b/database/seeders/SubClassificationSeeder.php
index 4578818..2f81c78 100644
--- a/database/seeders/SubClassificationSeeder.php
+++ b/database/seeders/SubClassificationSeeder.php
@@ -2,6 +2,7 @@
namespace Database\Seeders;
+use App\Models\SubClassification;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
@@ -12,6 +13,21 @@ class SubClassificationSeeder extends Seeder
*/
public function run(): void
{
- //
+ SubClassification::insert([
+ [
+ 'name' => 'Pembacokan',
+ 'slug' => 'pembacokan',
+ 'description' => null,
+ 'classification_id' => '2',
+ 'enhancer_id' => '1'
+ ],
+ [
+ 'name' => 'Tawuran',
+ 'slug' => 'tawuran',
+ 'description' => null,
+ 'classification_id' => '2',
+ 'enhancer_id' => '1'
+ ]
+ ]);
}
}
diff --git a/resources/views/dashboard/classifications/edit.blade.php b/resources/views/dashboard/classifications/edit.blade.php
index 7e37fc6..ad450fe 100644
--- a/resources/views/dashboard/classifications/edit.blade.php
+++ b/resources/views/dashboard/classifications/edit.blade.php
@@ -12,7 +12,7 @@
{{$title}}
-
diff --git a/resources/views/dashboard/government-agencies/create.blade.php b/resources/views/dashboard/government-agencies/create.blade.php
new file mode 100644
index 0000000..c712a25
--- /dev/null
+++ b/resources/views/dashboard/government-agencies/create.blade.php
@@ -0,0 +1,77 @@
+@include('partials.dashboard.head')
+@include('partials.dashboard.sidebar', ['page' => 'government_agencies'])
+@include('partials.dashboard.header')
+
+
+
+@include('partials.dashboard.footer', ['rich_editor' => true])
diff --git a/resources/views/dashboard/government-agencies/edit.blade.php b/resources/views/dashboard/government-agencies/edit.blade.php
new file mode 100644
index 0000000..87619f0
--- /dev/null
+++ b/resources/views/dashboard/government-agencies/edit.blade.php
@@ -0,0 +1,78 @@
+@include('partials.dashboard.head')
+@include('partials.dashboard.sidebar', ['page' => 'government_agencies'])
+@include('partials.dashboard.header')
+
+
+
+@include('partials.dashboard.footer', ['rich_editor' => true])
diff --git a/resources/views/dashboard/government-agencies/index.blade.php b/resources/views/dashboard/government-agencies/index.blade.php
new file mode 100644
index 0000000..cfb2a8e
--- /dev/null
+++ b/resources/views/dashboard/government-agencies/index.blade.php
@@ -0,0 +1,60 @@
+@include('partials.dashboard.head')
+@include('partials.dashboard.sidebar', ['page' => 'government_agencies'])
+@include('partials.dashboard.header')
+
+
+
+@include('partials.dashboard.footer' ,['datatable' => 'government_agency'])
diff --git a/resources/views/dashboard/government-agencies/show.blade.php b/resources/views/dashboard/government-agencies/show.blade.php
new file mode 100644
index 0000000..da1b7bc
--- /dev/null
+++ b/resources/views/dashboard/government-agencies/show.blade.php
@@ -0,0 +1,68 @@
+@include('partials.dashboard.head')
+@include('partials.dashboard.sidebar', ['page' => 'government_agencies'])
+@include('partials.dashboard.header')
+
+
+
+@include('partials.dashboard.footer', ['rich_editor' => true])
diff --git a/resources/views/dashboard/sub-classifications/create.blade.php b/resources/views/dashboard/sub-classifications/create.blade.php
index c0bcda4..faa3aac 100644
--- a/resources/views/dashboard/sub-classifications/create.blade.php
+++ b/resources/views/dashboard/sub-classifications/create.blade.php
@@ -19,7 +19,7 @@