fix(master-rule): change indicator table and rule table

This commit is contained in:
arieeefajar 2025-03-25 13:54:38 +07:00
parent c5d60fa5bc
commit 0b5c4823d6
4 changed files with 37 additions and 14 deletions

View File

@ -14,7 +14,6 @@ public function up(): void
Schema::create('indicators', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('description');
$table->timestamps();
});
}

View File

@ -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();
});

View File

@ -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) {

View File

@ -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) {