From d8df50a853b9b0e8e9a358543d06099ef273f769 Mon Sep 17 00:00:00 2001 From: rahmagustin Date: Wed, 14 Jan 2026 22:09:31 +0700 Subject: [PATCH] perbaikan database --- .../Controllers/Admin/AduanController.php | 0 app/Models/AduanTps.php | 1 + app/Models/KategoriTps.php | 1 + app/Models/LokasiTps.php | 1 + app/Models/Sampah.php | 1 + app/Models/User.php | 4 +++ ...01_14_132238_add_alamat_to_aduan_table.php | 25 ++++++++++++++ ...8_rename_id_to_id_users_in_users_table.php | 21 ++++++++++++ ...ename_id_to_id_tps_in_lokasi_tps_table.php | 21 ++++++++++++ ...kasi_tps_to_id_tps_in_lokasi_tps_table.php | 25 ++++++++++++++ ..._id_kategori_tps_in_kategori_tps_table.php | 25 ++++++++++++++ ...rename_id_to_id_sampah_in_sampah_table.php | 33 +++++++++++++++++++ ...name_id_to_id_aduan_in_aduan_tps_table.php | 33 +++++++++++++++++++ .../views/admin/kategori-tps/edit.blade.php | 2 +- .../views/admin/kategori-tps/index.blade.php | 4 +-- resources/views/admin/sampah/edit.blade.php | 2 +- resources/views/admin/sampah/index.blade.php | 4 +-- resources/views/admin/template.blade.php | 8 ++++- resources/views/admin/tps/edit.blade.php | 2 +- resources/views/admin/tps/index.blade.php | 4 +-- 20 files changed, 207 insertions(+), 10 deletions(-) create mode 100644 app/Http/Controllers/Admin/AduanController.php create mode 100644 database/migrations/2026_01_14_132238_add_alamat_to_aduan_table.php create mode 100644 database/migrations/2026_01_14_133328_rename_id_to_id_users_in_users_table.php create mode 100644 database/migrations/2026_01_14_133547_rename_id_to_id_tps_in_lokasi_tps_table.php create mode 100644 database/migrations/2026_01_14_134021_rename_id_lokasi_tps_to_id_tps_in_lokasi_tps_table.php create mode 100644 database/migrations/2026_01_14_134149_rename_id_to_id_kategori_tps_in_kategori_tps_table.php create mode 100644 database/migrations/2026_01_14_134254_rename_id_to_id_sampah_in_sampah_table.php create mode 100644 database/migrations/2026_01_14_134350_rename_id_to_id_aduan_in_aduan_tps_table.php diff --git a/app/Http/Controllers/Admin/AduanController.php b/app/Http/Controllers/Admin/AduanController.php new file mode 100644 index 0000000..e69de29 diff --git a/app/Models/AduanTps.php b/app/Models/AduanTps.php index c6e49a6..83d1c57 100644 --- a/app/Models/AduanTps.php +++ b/app/Models/AduanTps.php @@ -7,6 +7,7 @@ class AduanTps extends Model { protected $table = 'aduan_tps'; + protected $primaryKey = 'id_aduan'; protected $fillable = [ 'lokasi_tps_id', diff --git a/app/Models/KategoriTps.php b/app/Models/KategoriTps.php index cc5260d..ecbf4aa 100644 --- a/app/Models/KategoriTps.php +++ b/app/Models/KategoriTps.php @@ -7,6 +7,7 @@ class KategoriTps extends Model { protected $table = 'kategori_tps'; + protected $primaryKey = 'id_kategori_tps'; protected $fillable = [ 'nama_kategori', diff --git a/app/Models/LokasiTps.php b/app/Models/LokasiTps.php index 9160e30..deda36c 100644 --- a/app/Models/LokasiTps.php +++ b/app/Models/LokasiTps.php @@ -10,6 +10,7 @@ class LokasiTps extends Model use HasFactory; protected $table = 'lokasi_tps'; + protected $primaryKey = 'id_tps'; protected $fillable = [ 'kategori_tps_id', diff --git a/app/Models/Sampah.php b/app/Models/Sampah.php index e52ad11..c0aede3 100644 --- a/app/Models/Sampah.php +++ b/app/Models/Sampah.php @@ -7,6 +7,7 @@ class Sampah extends Model { protected $table = 'sampah'; + protected $primaryKey = 'id_sampah'; protected $fillable = [ 'user_id', diff --git a/app/Models/User.php b/app/Models/User.php index 0ff683d..b3921a3 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -10,6 +10,10 @@ class User extends Authenticatable use Notifiable; protected $table = 'users'; + protected $primaryKey = 'id_users'; + + public $incrementing = true; + protected $keyType = 'int'; protected $fillable = [ 'name', diff --git a/database/migrations/2026_01_14_132238_add_alamat_to_aduan_table.php b/database/migrations/2026_01_14_132238_add_alamat_to_aduan_table.php new file mode 100644 index 0000000..9bb62f7 --- /dev/null +++ b/database/migrations/2026_01_14_132238_add_alamat_to_aduan_table.php @@ -0,0 +1,25 @@ +string('alamat_pelapor')->after('nama_pelapor'); + }); + } + } + + public function down(): void + { + if (Schema::hasColumn('aduan_tps', 'alamat_pelapor')) { + Schema::table('aduan_tps', function (Blueprint $table) { + $table->dropColumn('alamat_pelapor'); + }); + } + } +}; diff --git a/database/migrations/2026_01_14_133328_rename_id_to_id_users_in_users_table.php b/database/migrations/2026_01_14_133328_rename_id_to_id_users_in_users_table.php new file mode 100644 index 0000000..eddc480 --- /dev/null +++ b/database/migrations/2026_01_14_133328_rename_id_to_id_users_in_users_table.php @@ -0,0 +1,21 @@ +renameColumn('id', 'id_users'); + }); + } + + public function down(): void + { + Schema::table('users', function (Blueprint $table) { + $table->renameColumn('id_users', 'id'); + }); + } +}; diff --git a/database/migrations/2026_01_14_133547_rename_id_to_id_tps_in_lokasi_tps_table.php b/database/migrations/2026_01_14_133547_rename_id_to_id_tps_in_lokasi_tps_table.php new file mode 100644 index 0000000..e79cd6e --- /dev/null +++ b/database/migrations/2026_01_14_133547_rename_id_to_id_tps_in_lokasi_tps_table.php @@ -0,0 +1,21 @@ +renameColumn('id', 'id_lokasi_tps'); + }); + } + + public function down(): void + { + Schema::table('lokasi_tps', function (Blueprint $table) { + $table->renameColumn('id_lokasi_tps', 'id'); + }); + } +}; diff --git a/database/migrations/2026_01_14_134021_rename_id_lokasi_tps_to_id_tps_in_lokasi_tps_table.php b/database/migrations/2026_01_14_134021_rename_id_lokasi_tps_to_id_tps_in_lokasi_tps_table.php new file mode 100644 index 0000000..8efcc1b --- /dev/null +++ b/database/migrations/2026_01_14_134021_rename_id_lokasi_tps_to_id_tps_in_lokasi_tps_table.php @@ -0,0 +1,25 @@ +renameColumn('id_lokasi_tps', 'id_tps'); + }); + } + } + + public function down(): void + { + + } +}; diff --git a/database/migrations/2026_01_14_134149_rename_id_to_id_kategori_tps_in_kategori_tps_table.php b/database/migrations/2026_01_14_134149_rename_id_to_id_kategori_tps_in_kategori_tps_table.php new file mode 100644 index 0000000..566be0c --- /dev/null +++ b/database/migrations/2026_01_14_134149_rename_id_to_id_kategori_tps_in_kategori_tps_table.php @@ -0,0 +1,25 @@ +renameColumn('id', 'id_kategori_tps'); + }); + } + } + + public function down(): void + { + + } +}; diff --git a/database/migrations/2026_01_14_134254_rename_id_to_id_sampah_in_sampah_table.php b/database/migrations/2026_01_14_134254_rename_id_to_id_sampah_in_sampah_table.php new file mode 100644 index 0000000..b8c1dee --- /dev/null +++ b/database/migrations/2026_01_14_134254_rename_id_to_id_sampah_in_sampah_table.php @@ -0,0 +1,33 @@ +renameColumn('id', 'id_sampah'); + }); + } + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('sampah', function (Blueprint $table) { + // + }); + } +}; diff --git a/database/migrations/2026_01_14_134350_rename_id_to_id_aduan_in_aduan_tps_table.php b/database/migrations/2026_01_14_134350_rename_id_to_id_aduan_in_aduan_tps_table.php new file mode 100644 index 0000000..12e04ac --- /dev/null +++ b/database/migrations/2026_01_14_134350_rename_id_to_id_aduan_in_aduan_tps_table.php @@ -0,0 +1,33 @@ +renameColumn('id', 'id_aduan'); + }); + } + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('aduan_tps', function (Blueprint $table) { + // + }); + } +}; diff --git a/resources/views/admin/kategori-tps/edit.blade.php b/resources/views/admin/kategori-tps/edit.blade.php index 13a3dfb..b5e52ce 100644 --- a/resources/views/admin/kategori-tps/edit.blade.php +++ b/resources/views/admin/kategori-tps/edit.blade.php @@ -9,7 +9,7 @@

Edit Kategori TPS

Form edit data kategori TPS

-
@csrf @method('PUT') diff --git a/resources/views/admin/kategori-tps/index.blade.php b/resources/views/admin/kategori-tps/index.blade.php index 2c1700e..4dd2e6b 100644 --- a/resources/views/admin/kategori-tps/index.blade.php +++ b/resources/views/admin/kategori-tps/index.blade.php @@ -46,11 +46,11 @@ {{ $item->deskripsi ?? '-' }} - - @csrf @method('DELETE') diff --git a/resources/views/admin/sampah/edit.blade.php b/resources/views/admin/sampah/edit.blade.php index 3cb277a..2574aba 100644 --- a/resources/views/admin/sampah/edit.blade.php +++ b/resources/views/admin/sampah/edit.blade.php @@ -11,7 +11,7 @@ Form edit data sampah per tahun (satuan Ton)

- + @csrf @method('PUT') diff --git a/resources/views/admin/sampah/index.blade.php b/resources/views/admin/sampah/index.blade.php index 8cc419c..699dca8 100644 --- a/resources/views/admin/sampah/index.blade.php +++ b/resources/views/admin/sampah/index.blade.php @@ -45,12 +45,12 @@ {{ $item->total_daur_ulang }} {{ $item->sisa_sampah }} - - @csrf @method('DELETE') diff --git a/resources/views/admin/template.blade.php b/resources/views/admin/template.blade.php index 07e6dea..09421e1 100644 --- a/resources/views/admin/template.blade.php +++ b/resources/views/admin/template.blade.php @@ -83,7 +83,7 @@ @@ -93,6 +93,12 @@ Kelola Sampah + diff --git a/resources/views/admin/tps/edit.blade.php b/resources/views/admin/tps/edit.blade.php index 7d25e88..7de36ad 100644 --- a/resources/views/admin/tps/edit.blade.php +++ b/resources/views/admin/tps/edit.blade.php @@ -11,7 +11,7 @@ Form edit data Tempat Pembuangan Sampah

- @csrf @method('PUT') diff --git a/resources/views/admin/tps/index.blade.php b/resources/views/admin/tps/index.blade.php index 6577159..edb62f5 100644 --- a/resources/views/admin/tps/index.blade.php +++ b/resources/views/admin/tps/index.blade.php @@ -70,12 +70,12 @@ - - @csrf @method('DELETE')