diff --git a/app/Enums/KeparahanSerangan.php b/app/Enums/KeparahanSerangan.php index a030eb9..3fb078a 100644 --- a/app/Enums/KeparahanSerangan.php +++ b/app/Enums/KeparahanSerangan.php @@ -11,9 +11,9 @@ enum KeparahanSerangan: string public function label(): string { return match($this) { - self::RINGAN => 'Ringan', - self::SEDANG => 'Sedang', - self::BERAT => 'Berat', + self::RINGAN => 'Ringan, hanya beberapa tanaman', + self::SEDANG => 'Sedang, sebagian tanaman terdampak', + self::BERAT => 'Parah, sebagian besar tanaman terdampak', }; } diff --git a/app/Enums/KondisiTanaman.php b/app/Enums/KondisiTanaman.php index ae73179..4193e4b 100644 --- a/app/Enums/KondisiTanaman.php +++ b/app/Enums/KondisiTanaman.php @@ -13,10 +13,10 @@ enum KondisiTanaman: string public function label(): string { return match($this) { - self::BAIK => 'Baik', - self::SEDANG => 'Sedang', - self::BURUK => 'Buruk', - self::MATI => 'Mati', + self::BAIK => 'Baik, tumbuh lebat, banyak buah', + self::SEDANG => 'Sedang, cukup tumbuh, ada masalah', + self::BURUK => 'Buruk, banyak tanaman tua dan lemah/tidak berbuah', + self::MATI => 'Mati, tanaman telah mati, tidak dapat tumbuh maupun berbuah', }; } diff --git a/app/Models/Pertanian/Lahan.php b/app/Models/Pertanian/Lahan.php index c8c57de..8021c23 100644 --- a/app/Models/Pertanian/Lahan.php +++ b/app/Models/Pertanian/Lahan.php @@ -56,7 +56,10 @@ class Lahan extends Model 'komoditas_lain', 'tanaman_penaung', - 'foto' + 'foto', + + 'jenis_hama', + 'jenis_penyakit', ]; protected $casts = [ @@ -68,7 +71,9 @@ class Lahan extends Model 'serangan_hama' => SeranganHama::class, 'penyakit_tanaman' => PenyakitTanaman::class, 'keparahan_serangan' => KeparahanSerangan::class, - 'foto' => 'array' + 'foto' => 'array', + 'jenis_hama' => 'array', + 'jenis_penyakit' => 'array' ]; public function profile(): BelongsTo diff --git a/app/Models/Pertanian/PraktikBudidaya.php b/app/Models/Pertanian/PraktikBudidaya.php index 0a3782c..ba99cff 100644 --- a/app/Models/Pertanian/PraktikBudidaya.php +++ b/app/Models/Pertanian/PraktikBudidaya.php @@ -12,6 +12,8 @@ use Illuminate\Support\Str; use App\Models\Pertanian\Petani; use App\Models\Pertanian\SkorPetani; +use App\Models\Pertanian\Tanaman; +use App\Models\Pertanian\Lahan; class PraktikBudidaya extends Model { @@ -115,6 +117,19 @@ class PraktikBudidaya extends Model 'skor_d2_k2_7_penglolaan_air_irigasi' => $praktikBudidaya->kondisi_pengelolaan_air, 'skor_d2_k2_8_praktik_konservasi_tanah' => $skor_konservasi_tanah, ]); + + Lahan::where('petani_id', $petani->id)->update([ + 'jenis_hama' => $praktikBudidaya->jenis_hama, + 'jenis_penyakit' => $praktikBudidaya->jenis_penyakit, + ]); + + Tanaman::whereIn( + 'lahan_id', + Lahan::where('petani_id', $petani->id)->select('id') + )->update([ + 'jenis_hama' => $praktikBudidaya->jenis_hama, + 'jenis_penyakit' => $praktikBudidaya->jenis_penyakit, + ]); }); } diff --git a/app/Models/Pertanian/Tanaman.php b/app/Models/Pertanian/Tanaman.php index e31a616..72febdf 100644 --- a/app/Models/Pertanian/Tanaman.php +++ b/app/Models/Pertanian/Tanaman.php @@ -42,6 +42,9 @@ class Tanaman extends Model 'serangan_hama', 'penyakit_tanaman', 'keparahan_serangan', + + 'jenis_hama', + 'jenis_penyakit', ]; protected $casts = [ @@ -49,6 +52,8 @@ class Tanaman extends Model 'serangan_hama' => SeranganHama::class, 'penyakit_tanaman' => PenyakitTanaman::class, 'keparahan_serangan' => KeparahanSerangan::class, + 'jenis_hama' => 'array', + 'jenis_penyakit' => 'array' ]; public function komoditas() diff --git a/database/migrations/2026_07_22_110145_update_lahan_tanaman_table.php b/database/migrations/2026_07_22_110145_update_lahan_tanaman_table.php new file mode 100644 index 0000000..c3f4a9e --- /dev/null +++ b/database/migrations/2026_07_22_110145_update_lahan_tanaman_table.php @@ -0,0 +1,37 @@ +jsonb('jenis_hama')->nullable(); + $table->jsonb('jenis_penyakit')->nullable(); + }); + + Schema::table('map_tanaman', function (Blueprint $table) { + $table->jsonb('jenis_hama')->nullable(); + $table->jsonb('jenis_penyakit')->nullable(); + }); + } + + public function down(): void + { + Schema::table('map_lahan', function (Blueprint $table) { + $table->dropColumn('jenis_hama'); + $table->dropColumn('jenis_penyakit'); + }); + + Schema::table('map_tanaman', function (Blueprint $table) { + $table->dropColumn('jenis_hama'); + $table->dropColumn('jenis_penyakit'); + }); + } +}; diff --git a/resources/views/produktivitas/petani/header.blade.php b/resources/views/produktivitas/petani/header.blade.php index 15c31de..8ecf1b9 100644 --- a/resources/views/produktivitas/petani/header.blade.php +++ b/resources/views/produktivitas/petani/header.blade.php @@ -90,7 +90,7 @@

Lahan & Tanaman

@if($lahanPetani->isNotEmpty()) - {{ number_format($totalLuasLahan, 0, ',', '.') }} m2 + {{ number_format($totalLuasLahan, 0, ',', '.') }} ha @else - @endif diff --git a/resources/views/produktivitas/petani/index.blade.php b/resources/views/produktivitas/petani/index.blade.php index 33ae852..b6cb010 100644 --- a/resources/views/produktivitas/petani/index.blade.php +++ b/resources/views/produktivitas/petani/index.blade.php @@ -15,7 +15,7 @@
- - + + @error('luas_lahan')
{{ $message }}
@enderror
@@ -247,17 +247,124 @@
-
+
@error('kondisi_tanaman')
{{ $message }}
@enderror
-
+
+
+
+ + +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ * Tidak diisi, terisi otomatis + @error('jenis_hama') +
{{ $message }}
+ @enderror +
+
+ + +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ * Tidak diisi, terisi otomatis + + @error('jenis_penyakit') +
{{ $message }}
+ @enderror +
+ +
@error('keparahan_serangan')
{{ $message }}
@enderror
@@ -657,9 +764,9 @@ let area = L.GeometryUtil.geodesicArea(latlngs); - console.log(area); + let areaHa = area / 10000; - $('#luas_lahan').val(area.toFixed(2)); + $('#luas_lahan').val(areaHa.toFixed(4)); } const previewTemplate = ` @@ -815,7 +922,7 @@ let originalText = submitBtn.html(); submitBtn.prop('disabled', true).html(' Menyimpan...'); - $.ajax({ + $.ajax({ url: $(form).attr('action'), type: "POST", data: formData, @@ -833,7 +940,7 @@ showConfirmButton: false, timer: 1500 }).then(() => { - window.location.href = "{{ route('petani.index') }}"; + window.location.href = "{{ route('petani.lahan-tanaman.index', ['petani' => $petani->id]) }}"; }); }, error: function(xhr) { diff --git a/resources/views/produktivitas/petani/lahan/edit.blade.php b/resources/views/produktivitas/petani/lahan/edit.blade.php index 391dd8e..d0e7d2a 100644 --- a/resources/views/produktivitas/petani/lahan/edit.blade.php +++ b/resources/views/produktivitas/petani/lahan/edit.blade.php @@ -73,7 +73,7 @@
- + @error('luas_lahan')
{{ $message }}
@enderror @@ -129,17 +129,19 @@
-
+
@error('kondisi_tanaman')
{{ $message }}
@enderror
-
+
+
+ +
+ + +
+ jenis_hama ?? [])) ? 'checked' : '' }}> + +
+ +
+ jenis_hama ?? [])) ? 'checked' : '' }}> + +
+ +
+ jenis_hama ?? [])) ? 'checked' : '' }}> + +
+ +
+ jenis_hama ?? [])) ? 'checked' : '' }}> + +
+ +
+ jenis_hama ?? [])) ? 'checked' : '' }}> + +
+ * Tidak diisi, terisi otomatis + @error('jenis_hama') +
{{ $message }}
+ @enderror
-
+
+ + +
+ jenis_penyakit ?? [])) ? 'checked' : '' }} + +
+ +
+ jenis_penyakit ?? [])) ? 'checked' : '' }} + +
+ +
+ jenis_penyakit ?? [])) ? 'checked' : '' }} + +
+ +
+ jenis_penyakit ?? [])) ? 'checked' : '' }} + +
+ +
+ jenis_penyakit ?? [])) ? 'checked' : '' }} + +
+ * Tidak diisi, terisi otomatis + + @error('jenis_penyakit') +
{{ $message }}
+ @enderror +
+
@error('keparahan_serangan')
{{ $message }}
@enderror