From fcb11aba9973afca7e98d3a583fa68c6ff5259b6 Mon Sep 17 00:00:00 2001 From: rahmagustin Date: Thu, 15 Jan 2026 21:07:10 +0700 Subject: [PATCH] aduan admin --- .../Controllers/Admin/AduanController.php | 55 +++++++++ app/Models/AduanTps.php | 5 +- ...21019_add_tanggapan_to_aduan_tps_table.php | 22 ++++ ...rop_alamat_column_from_aduan_tps_table.php | 21 ++++ resources/views/admin/aduan/create.blade.php | 62 ---------- resources/views/admin/aduan/edit.blade.php | 86 ++++++++------ resources/views/admin/aduan/index.blade.php | 106 ++++++++---------- resources/views/admin/template.blade.php | 31 ++--- routes/web.php | 7 ++ 9 files changed, 217 insertions(+), 178 deletions(-) create mode 100644 database/migrations/2026_01_15_121019_add_tanggapan_to_aduan_tps_table.php create mode 100644 database/migrations/2026_01_15_125324_drop_alamat_column_from_aduan_tps_table.php delete mode 100644 resources/views/admin/aduan/create.blade.php diff --git a/app/Http/Controllers/Admin/AduanController.php b/app/Http/Controllers/Admin/AduanController.php index e69de29..fc93fab 100644 --- a/app/Http/Controllers/Admin/AduanController.php +++ b/app/Http/Controllers/Admin/AduanController.php @@ -0,0 +1,55 @@ +orderBy('tanggal_aduan', 'desc') + ->get(); + + return view('admin.aduan.index', compact('aduan')); + } + + public function show($id) + { + $aduan = AduanTps::findOrFail($id); + return view('admin.aduan.edit', compact('aduan')); + } + + public function tanggapi(Request $request, $id) + { + $request->validate([ + 'tanggapan_admin' => 'required' + ]); + + $aduan = AduanTps::findOrFail($id); + $aduan->tanggapan_admin = $request->tanggapan_admin; + $aduan->tanggal_tanggapan = now(); + $aduan->save(); + + return redirect()->route('admin.aduan.index') + ->with('success', 'Tanggapan berhasil disimpan'); + } + + /** + * Hapus tanggapan admin + */ + public function destroy($id) + { + $aduan = AduanTps::findOrFail($id); + $aduan->delete(); + + return redirect()->route('admin.aduan.index') + ->with('success', 'Aduan berhasil dihapus'); + } +} diff --git a/app/Models/AduanTps.php b/app/Models/AduanTps.php index 83d1c57..77725fa 100644 --- a/app/Models/AduanTps.php +++ b/app/Models/AduanTps.php @@ -12,10 +12,13 @@ class AduanTps extends Model protected $fillable = [ 'lokasi_tps_id', 'nama_pelapor', + 'alamat_pelapor', 'no_pelapor', 'isi_aduan', 'tanggal_aduan', - 'bukti_foto' + 'bukti_foto', + 'tanggapan_admin', + 'tanggal_tanggapan' ]; public function lokasiTps() diff --git a/database/migrations/2026_01_15_121019_add_tanggapan_to_aduan_tps_table.php b/database/migrations/2026_01_15_121019_add_tanggapan_to_aduan_tps_table.php new file mode 100644 index 0000000..3e67daa --- /dev/null +++ b/database/migrations/2026_01_15_121019_add_tanggapan_to_aduan_tps_table.php @@ -0,0 +1,22 @@ +text('tanggapan_admin')->nullable()->after('bukti_foto'); + $table->dateTime('tanggal_tanggapan')->nullable()->after('tanggapan_admin'); + }); + } + + public function down() + { + Schema::table('aduan_tps', function (Blueprint $table) { + $table->dropColumn(['tanggapan_admin', 'tanggal_tanggapan']); + }); + } +}; diff --git a/database/migrations/2026_01_15_125324_drop_alamat_column_from_aduan_tps_table.php b/database/migrations/2026_01_15_125324_drop_alamat_column_from_aduan_tps_table.php new file mode 100644 index 0000000..29ee335 --- /dev/null +++ b/database/migrations/2026_01_15_125324_drop_alamat_column_from_aduan_tps_table.php @@ -0,0 +1,21 @@ +dropColumn('alamat'); + }); + } + + public function down() + { + Schema::table('aduan_tps', function (Blueprint $table) { + $table->string('alamat', 255)->after('alamat_pelapor'); + }); + } +}; diff --git a/resources/views/admin/aduan/create.blade.php b/resources/views/admin/aduan/create.blade.php deleted file mode 100644 index 8b801bb..0000000 --- a/resources/views/admin/aduan/create.blade.php +++ /dev/null @@ -1,62 +0,0 @@ -@extends('admin.template') - -@section('content') -
-
-
-
-
-

Basic form elements

-

- Basic form elements -

-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
- - - - -
-
-
- - -
-
- - -
- - -
-
-
-
-
-
-@endsection diff --git a/resources/views/admin/aduan/edit.blade.php b/resources/views/admin/aduan/edit.blade.php index 8b801bb..c24a2b9 100644 --- a/resources/views/admin/aduan/edit.blade.php +++ b/resources/views/admin/aduan/edit.blade.php @@ -6,54 +6,68 @@
-

Basic form elements

+

Tanggapi Aduan

- Basic form elements + Form tanggapan admin terhadap aduan masyarakat

-
+ + + @csrf + +
- - + +
+ +
- - + +
+ +
- - + +
-
- - -
-
- - -
- - - - + + + @if ($aduan->bukti_foto) +
+
+ Bukti Aduan
-
+ @endif + +
- - + +
-
- - -
- - + + + + + Kembali + +
diff --git a/resources/views/admin/aduan/index.blade.php b/resources/views/admin/aduan/index.blade.php index 164d64d..48c1b28 100644 --- a/resources/views/admin/aduan/index.blade.php +++ b/resources/views/admin/aduan/index.blade.php @@ -7,20 +7,14 @@
- +
-

Basic Table

+

Data Aduan

- Add class .table + Daftar aduan masyarakat

- - - Tambah - - -
@@ -28,62 +22,54 @@ - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @forelse ($aduan as $item) + + + + + + + + @empty + + + + @endforelse
ProfileVatNo.CreatedNama PelaporAlamatTanggal Aduan Status Aksi
Jacob5327553112 May 2017 - - - - - - -
Messsy5327553215 May 2017 - - - - - - -
John5327553314 May 2017
Peter5327553416 May 2017
Dave5327553520 May 2017
{{ $item->nama_pelapor }}{{ $item->alamat_pelapor }} + {{ \Carbon\Carbon::parse($item->tanggal_aduan)->format('d M Y') }} + + @if ($item->tanggapan_admin) + + @else + + @endif + + + + + +
+ @csrf + @method('DELETE') + +
+
+ Data aduan belum tersedia +
diff --git a/resources/views/admin/template.blade.php b/resources/views/admin/template.blade.php index 09421e1..46c65c5 100644 --- a/resources/views/admin/template.blade.php +++ b/resources/views/admin/template.blade.php @@ -69,55 +69,48 @@
@yield('content') - +
diff --git a/routes/web.php b/routes/web.php index e69dc8c..4279dfa 100644 --- a/routes/web.php +++ b/routes/web.php @@ -2,6 +2,7 @@ use App\Http\Controllers\SigController; use App\Http\Controllers\AboutController; +use App\Http\Controllers\Admin\AduanController as AdminAduanController; use App\Http\Controllers\Admin\DashboardController; use App\Http\Controllers\Admin\KategoriTpsController; use App\Http\Controllers\Admin\LoginController; @@ -75,4 +76,10 @@ Route::get('/sampah/{id}/edit', [SampahController::class, 'edit'])->name('sampah.edit'); Route::put('/sampah/{id}', [SampahController::class, 'update'])->name('sampah.update'); Route::delete('/sampah/{id}', [SampahController::class, 'destroy'])->name('sampah.destroy'); + + // ADUAN ADMIN + Route::get('/aduan', [AdminAduanController::class, 'index'])->name('aduan.index'); + Route::get('/aduan/{id}', [AdminAduanController::class, 'show'])->name('aduan.show'); + Route::post('/aduan/{id}/tanggapi', [AdminAduanController::class, 'tanggapi'])->name('aduan.tanggapi'); + Route::post('/aduan/{id}', [AdminAduanController::class, 'destroy'])->name('aduan.destroy'); });