From 0b5c4823d662b043fa67b3f1af9e601130c01843 Mon Sep 17 00:00:00 2001 From: arieeefajar Date: Tue, 25 Mar 2025 13:54:38 +0700 Subject: [PATCH 1/6] fix(master-rule): change indicator table and rule table --- ...25_01_28_120615_create_indicator_table.php | 1 - .../2025_02_06_084905_create_rule_table.php | 6 ++-- database/seeders/IndicatorSeeder.php | 10 +++--- database/seeders/RuleSeeder.php | 34 ++++++++++++++++--- 4 files changed, 37 insertions(+), 14 deletions(-) diff --git a/database/migrations/2025_01_28_120615_create_indicator_table.php b/database/migrations/2025_01_28_120615_create_indicator_table.php index b89d5c9..15902f1 100644 --- a/database/migrations/2025_01_28_120615_create_indicator_table.php +++ b/database/migrations/2025_01_28_120615_create_indicator_table.php @@ -14,7 +14,6 @@ public function up(): void Schema::create('indicators', function (Blueprint $table) { $table->id(); $table->string('name'); - $table->string('description'); $table->timestamps(); }); } diff --git a/database/migrations/2025_02_06_084905_create_rule_table.php b/database/migrations/2025_02_06_084905_create_rule_table.php index 631ce0d..89fdd2b 100644 --- a/database/migrations/2025_02_06_084905_create_rule_table.php +++ b/database/migrations/2025_02_06_084905_create_rule_table.php @@ -14,9 +14,9 @@ public function up(): void Schema::create('rule', function (Blueprint $table) { $table->id(); $table->unsignedBigInteger('indicator_id'); - $table->float('ideal_min'); - $table->float('ideal_max'); - $table->float('mb'); + $table->string('parameter_type'); + $table->string('description'); + $table->float('cf'); $table->timestamps(); }); diff --git a/database/seeders/IndicatorSeeder.php b/database/seeders/IndicatorSeeder.php index 702aaaa..76a5cc7 100644 --- a/database/seeders/IndicatorSeeder.php +++ b/database/seeders/IndicatorSeeder.php @@ -14,11 +14,11 @@ class IndicatorSeeder extends Seeder public function run(): void { $indicator = [ - ['name' => 'pH Tanah', 'description' => 'Indicator 1 Description'], - ['name' => 'Ketinggian Tempat', 'description' => 'Indicator 2 Description'], - ['name' => 'Ketersediaan Air', 'description' => 'Indicator 3 Description'], - ['name' => 'Curah Hujan', 'description' => 'Indicator 4 Description'], - ['name' => 'Isolasi', 'description' => 'Indicator 5 Description'] + ['name' => 'pH Tanah'], + ['name' => 'Ketinggian Tempat'], + ['name' => 'Ketersediaan Air'], + ['name' => 'Curah Hujan'], + ['name' => 'Isolasi'] ]; foreach ($indicator as $item) { diff --git a/database/seeders/RuleSeeder.php b/database/seeders/RuleSeeder.php index 4b85ad9..1c00cf5 100644 --- a/database/seeders/RuleSeeder.php +++ b/database/seeders/RuleSeeder.php @@ -14,11 +14,35 @@ class RuleSeeder extends Seeder public function run(): void { $rules = [ - ['indicator_id' => 1, 'ideal_min' => 5.5, 'ideal_max' => 7, 'mb' => 0.9], - ['indicator_id' => 2, 'ideal_min' => 0, 'ideal_max' => 1500, 'mb' => 0.8], - ['indicator_id' => 3, 'ideal_min' => 70, 'ideal_max' => 100, 'mb' => 0.7], - ['indicator_id' => 4, 'ideal_min' => 1000, 'ideal_max' => 2000, 'mb' => 0.9], - ['indicator_id' => 5, 'ideal_min' => 0, 'ideal_max' => 100, 'mb' => 0.8], + // pH Tanah + ['indicator_id' => 1, 'parameter_type' => "Sangat Asam", 'description' => "Tingkat keasaman pH tanah kurang dari 5.5", 'cf' => -0.6], + ['indicator_id' => 1, 'parameter_type' => "Asam", 'description' => "Tingkat keasaman pH tanah antara 5.5 - 6.0", 'cf' => 0.6], + ['indicator_id' => 1, 'parameter_type' => "Netral", 'description' => "Tingkat keasaman pH tanah antara 6.1 - 7.0", 'cf' => 1.0], + ['indicator_id' => 1, 'parameter_type' => "Basa", 'description' => "Tingkat keasaman pH tanah antara 7.1 - 7.5", 'cf' => 0.6], + ['indicator_id' => 1, 'parameter_type' => "Sangat Basa", 'description' => "Tingkat keasaman pH tanah lebih besar dari 7.5", 'cf' => -0.4], + + // Ketinggian Tempat + ['indicator_id' => 2, 'parameter_type' => "Rendah", 'description' => "Lahan berada di dataran rendah (<300 mdpl)", 'cf' => 1.0], + ['indicator_id' => 2, 'parameter_type' => "Sedang", 'description' => "Lahan berada di ketinggian sedang (300 - 700 mdpl)", 'cf' => 0.7], + ['indicator_id' => 2, 'parameter_type' => "Tinggi", 'description' => "Lahan berada di dataran tinggi (>700 mdpl)", 'cf' => -0.5], + + // Ketersediaan Air + ['indicator_id' => 3, 'parameter_type' => "Berlimpah", 'description' => "Irigasi teknis, air selalu tersedia sepanjang tahun", 'cf' => 1.0], + ['indicator_id' => 3, 'parameter_type' => "Cukup", 'description' => "Sumber air stabil, tetapi tidak selalu tersedia", 'cf' => 0.8], + ['indicator_id' => 3, 'parameter_type' => "Terbatas", 'description' => "Kadang-kadang mengalami kekeringan", 'cf' => -0.5], + ['indicator_id' => 3, 'parameter_type' => "Sangat Terbatas", 'description' => "Sering mengalami kekeringan", 'cf' => -0.8], + + // Curah Hujan + ['indicator_id' => 4, 'parameter_type' => "Rendah", 'description' => "Curah hujan kurang dari 1000 mm/tahun", 'cf' => -0.6], + ['indicator_id' => 4, 'parameter_type' => "Sedang", 'description' => "Curah hujan antara 1000 - 1500 mm/tahun", 'cf' => 0.6], + ['indicator_id' => 4, 'parameter_type' => "Tinggi", 'description' => "Curah hujan antara 1500 - 2000 mm/tahun", 'cf' => 0.8], + ['indicator_id' => 4, 'parameter_type' => "Sangat Tinggi", 'description' => "Curah hujan lebih dari 2000 mm/tahun", 'cf' => -0.4], + + // Isolasi (Jarak Antar Lahan) + ['indicator_id' => 5, 'parameter_type' => "Sangat Baik", 'description' => "Jarak antar lahan sangat dekat (0 - 50 meter)", 'cf' => 1.0], + ['indicator_id' => 5, 'parameter_type' => "Baik", 'description' => "Jarak antar lahan cukup dekat (50 - 200 meter)", 'cf' => 0.8], + ['indicator_id' => 5, 'parameter_type' => "Sedang", 'description' => "Jarak antar lahan cukup jauh (200 - 500 meter)", 'cf' => -0.4], + ['indicator_id' => 5, 'parameter_type' => "Buruk", 'description' => "Lahan sangat terisolasi (>500 meter)", 'cf' => -0.7], ]; foreach ($rules as $rule) { From 2450d3af4f55de7200b1dc7b9e645136cab61fe1 Mon Sep 17 00:00:00 2001 From: arieeefajar Date: Tue, 25 Mar 2025 14:05:33 +0700 Subject: [PATCH 2/6] fix(master-rule) fixed crud function indicator --- .../MasterData/IndicatorController.php | 14 +--------- .../customJs/master-data/indikator/index.js | 4 +-- .../master-data/indikator/index.blade.php | 26 +++---------------- 3 files changed, 5 insertions(+), 39 deletions(-) diff --git a/app/Http/Controllers/MasterData/IndicatorController.php b/app/Http/Controllers/MasterData/IndicatorController.php index 5d8dca7..730300b 100644 --- a/app/Http/Controllers/MasterData/IndicatorController.php +++ b/app/Http/Controllers/MasterData/IndicatorController.php @@ -11,7 +11,7 @@ class IndicatorController extends Controller { public function index() { - $indicators = Indicator::all(); + $indicators = Indicator::select('id', 'name')->orderBy('created_at', 'desc')->get(); return view('master-data.indikator.index', compact('indicators')); } @@ -21,15 +21,10 @@ public function store(Request $request) "name.required" => "Nama wajib diisi", "name.max" => "Nama maksimal 25 karakter", "name.string" => "Nama harus berupa string", - - "description.required" => "Deskripsi wajib diisi", - "description.max" => "Deskripsi maksimal 50 karakter", - "description.string" => "Deskripsi harus berupa string", ]; $validator = Validator::make($request->all(), [ 'name' => 'required|string|max:25', - 'description' => 'required|string|max:50', ], $customMessage); if ($validator->fails()) { @@ -39,7 +34,6 @@ public function store(Request $request) $indicator = new Indicator(); $indicator->name = $request->name; - $indicator->description = $request->description; try { $indicator->save(); @@ -57,15 +51,10 @@ public function update(Request $request, $id) "name.required" => "Nama wajib diisi", "name.max" => "Nama maksimal 25 karakter", "name.string" => "Nama harus berupa string", - - "description.required" => "Deskripsi wajib diisi", - "description.max" => "Deskripsi maksimal 50 karakter", - "description.string" => "Deskripsi harus berupa string", ]; $validator = Validator::make($request->all(), [ 'name' => 'required|string|max:25', - 'description' => 'required|string|max:50', ], $customMessage); if ($validator->fails()) { @@ -75,7 +64,6 @@ public function update(Request $request, $id) $indicator = Indicator::find($id); $indicator->name = $request->name; - $indicator->description = $request->description; try { $indicator->save(); diff --git a/public/assets/js/pages/customJs/master-data/indikator/index.js b/public/assets/js/pages/customJs/master-data/indikator/index.js index bf46060..a8d0dd2 100644 --- a/public/assets/js/pages/customJs/master-data/indikator/index.js +++ b/public/assets/js/pages/customJs/master-data/indikator/index.js @@ -20,10 +20,8 @@ document.addEventListener("DOMContentLoaded", function () { function updateData(indicator) { var form = document.getElementById("edit-form"); var indicatorName = form.querySelector('input[name="name"]'); - var description = form.querySelector('textarea[name="description"]'); indicatorName.value = indicator.name; - description.value = indicator.description; form.action = "/data-indikator/" + indicator.id; } @@ -50,7 +48,7 @@ checkAll && }); var perPage = 8, options = { - valueNames: ["id", "indicator_name", "status"], + valueNames: ["id", "status"], page: perPage, pagination: !0, plugins: [ListPagination({ left: 2, right: 2 })], diff --git a/resources/views/master-data/indikator/index.blade.php b/resources/views/master-data/indikator/index.blade.php index 9b12bdf..6b4018f 100644 --- a/resources/views/master-data/indikator/index.blade.php +++ b/resources/views/master-data/indikator/index.blade.php @@ -61,7 +61,6 @@ Name - Description Action @@ -73,9 +72,8 @@ #VZ2101 - {{ $indicator->name }} - {{ $indicator->description }} + {{ $indicator->name }}
@@ -151,7 +149,7 @@ class="fw-medium link-primary">#VZ2101 readonly />
-
+
#VZ2101 Masukan Nama Indikator
- -
- - -
- Masukan Deskripsi -
-