Compare commits
226
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
712b10e405 | ||
|
|
6cfcf46ba6 | ||
|
|
b1b9828514 | ||
|
|
7af7e1bdaf | ||
|
|
bd05fc7f0f | ||
|
|
17b5687db8 | ||
|
|
e7f48b6500 | ||
|
|
a5884d0f8c | ||
|
|
9576c6295e | ||
|
|
079e300d5d | ||
|
|
2c94316439 | ||
|
|
690b53e5a2 | ||
|
|
50c9adfdc7 | ||
|
|
696c7dede8 | ||
|
|
5967e7d6f3 | ||
|
|
4c66d72dc5 | ||
|
|
c43483a9f8 | ||
|
|
e02a34a527 | ||
|
|
713355ce0a | ||
|
|
12f8d0bbda | ||
|
|
8afe7f9b38 | ||
|
|
fbf84eb4cb | ||
|
|
e04093ad3f | ||
|
|
3e1d3a33ee | ||
|
|
e316d064ef | ||
|
|
0c289ec244 | ||
|
|
089f1b515d | ||
|
|
4c647ea8ce | ||
|
|
419404e273 | ||
|
|
837e542851 | ||
|
|
9378d15d71 | ||
|
|
0381e9bf0e | ||
|
|
3a70445e9a | ||
|
|
d2ed2c58fd | ||
|
|
9b201efa06 | ||
|
|
2b3a0b7c58 | ||
|
|
a187fb1095 | ||
|
|
6b44c11181 | ||
|
|
090153e53a | ||
|
|
a79a93d291 | ||
|
|
62f0f1bdbc | ||
|
|
f0acd8c7ed | ||
|
|
3908b0be71 | ||
|
|
05cc3be9d3 | ||
|
|
f4c83d348a | ||
|
|
61bd8dc388 | ||
|
|
002d6044b4 | ||
|
|
30196278d7 | ||
|
|
08c19c0714 | ||
|
|
d6c036e19a | ||
|
|
981bc0d494 | ||
|
|
857da1e900 | ||
|
|
66fc7227e6 | ||
|
|
3edfc57ba7 | ||
|
|
4a560ebc4e | ||
|
|
d4eb27e583 | ||
|
|
d1c0f90afd | ||
|
|
a1dadd1b1b | ||
|
|
2c28bb06db | ||
|
|
96a53c8754 | ||
|
|
fcc5d7dcc5 | ||
|
|
e383aacbeb | ||
|
|
5b776b2ae8 | ||
|
|
c4e3e460b1 | ||
|
|
a7dc1dc58b | ||
|
|
d01c737364 | ||
|
|
8d50757b51 | ||
|
|
f146cb2608 | ||
|
|
095d84ec7f | ||
|
|
f259c6728a | ||
|
|
a241a62136 | ||
|
|
4755c8a482 | ||
|
|
7672877299 | ||
|
|
92e8efb247 | ||
|
|
599269410b | ||
|
|
c5b5721b31 | ||
|
|
2bf2a68a3a | ||
|
|
b445392e9f | ||
|
|
bcc15d5240 | ||
|
|
d33bc8a42b | ||
|
|
df5bfeb67f | ||
|
|
b0e1f3f131 | ||
|
|
a19871366a | ||
|
|
b4b851c7a9 | ||
|
|
e6f6257434 | ||
|
|
469e57ba28 | ||
|
|
d06da22ae5 | ||
|
|
350df6adcf | ||
|
|
1788efaed5 | ||
|
|
d49bd4953c | ||
|
|
26f6e83328 | ||
|
|
79f6426125 | ||
|
|
9557d1ec64 | ||
|
|
7bab43df71 | ||
|
|
316b256ae0 | ||
|
|
bfabab96c5 | ||
|
|
bd9b0873a3 | ||
|
|
3464a802e2 | ||
|
|
6c95c462cb | ||
|
|
626fdba065 | ||
|
|
2152079b26 | ||
|
|
6559a97f43 | ||
|
|
05c2e53378 | ||
|
|
3df381a66c | ||
|
|
6fac76127d | ||
|
|
a1d9b34d93 | ||
|
|
c01ba6a906 | ||
|
|
4976948bc6 | ||
|
|
734c3fba65 | ||
|
|
457288b325 | ||
|
|
9220cf23c2 | ||
|
|
884b911767 | ||
|
|
e1fde05ba0 | ||
|
|
74572fe586 | ||
|
|
2eb40f8a1a | ||
|
|
ff3f930939 | ||
|
|
b3d805fe98 | ||
|
|
e2c778a934 | ||
|
|
34865b34be | ||
|
|
11d836713a | ||
|
|
f448257980 | ||
|
|
f9f507a115 | ||
|
|
6ddf978ba7 | ||
|
|
1fd47b517b | ||
|
|
13c71d2612 | ||
|
|
d0e41dc1d2 | ||
|
|
21679486ea | ||
|
|
7cd32b1116 | ||
|
|
e9e598616e | ||
|
|
bd40cd9357 | ||
|
|
eea9f4dec8 | ||
|
|
27e084bc9e | ||
|
|
3b1a0f52dd | ||
|
|
5cee65f8df | ||
|
|
5c1fe22fa0 | ||
|
|
8886629e02 | ||
|
|
e1979b51dd | ||
|
|
55598fbf1d | ||
|
|
90f13438db | ||
|
|
c454a0b453 | ||
|
|
a4a81447ab | ||
|
|
c4ff20facd | ||
|
|
8710176b2c | ||
|
|
10df07b473 | ||
|
|
cc6a732de7 | ||
|
|
839e9aa572 | ||
|
|
280f76510e | ||
|
|
02890ae9ae | ||
|
|
1517dd38cf | ||
|
|
871b015ce2 | ||
|
|
7d40bcfb53 | ||
|
|
aecca02269 | ||
|
|
d5f1a5f625 | ||
|
|
cdbfff4424 | ||
|
|
e640cba74f | ||
|
|
18bdb3abca | ||
|
|
8cba4118bf | ||
|
|
f8304f8f84 | ||
|
|
8ead70787c | ||
|
|
d7e2cd7692 | ||
|
|
9d3b64a54d | ||
|
|
35b50cba36 | ||
|
|
b6c94ddb07 | ||
|
|
bf1fe7fcfe | ||
|
|
f270c1f0b6 | ||
|
|
482c3fc474 | ||
|
|
d509a79576 | ||
|
|
a355a1d1d8 | ||
|
|
f11be9d288 | ||
|
|
dca09168c9 | ||
|
|
af170284c8 | ||
|
|
f7cdeca2e6 | ||
|
|
316a98dc15 | ||
|
|
7a4199e3f0 | ||
|
|
381a9662ea | ||
|
|
b15504e009 | ||
|
|
7cc3e0e8f1 | ||
|
|
4021010618 | ||
|
|
58bb2951f7 | ||
|
|
17d384acf9 | ||
|
|
751f14cb02 | ||
|
|
0db7ca1fa9 | ||
|
|
7ec111274f | ||
|
|
d13069cd78 | ||
|
|
8e83413d34 | ||
|
|
a48d6d75b6 | ||
|
|
1d37da0edc | ||
|
|
02037ff0be | ||
|
|
7bf92ea619 | ||
|
|
3ce013c754 | ||
|
|
6ff0ef011c | ||
|
|
c4e4f396d2 | ||
|
|
fd42bf37fe | ||
|
|
b702659215 | ||
|
|
7681984d89 | ||
|
|
e194658c28 | ||
|
|
17c4c96693 | ||
|
|
05967cce75 | ||
|
|
fa90501455 | ||
|
|
a274f84fe2 | ||
|
|
12f0686965 | ||
|
|
e4f7d675a1 | ||
|
|
9231f25e5d | ||
|
|
037c482649 | ||
|
|
3f37dcb51e | ||
|
|
b08df8f6fa | ||
|
|
6341199fd5 | ||
|
|
60063b86ba | ||
|
|
7e8ad932a4 | ||
|
|
7669511220 | ||
|
|
5f6dbb4d1e | ||
|
|
9e748fc8cd | ||
|
|
1ca9d96779 | ||
|
|
6c0c47751c | ||
|
|
75d679f492 | ||
|
|
e9abd33d85 | ||
|
|
e0ab4bdace | ||
|
|
34d09d03bb | ||
|
|
36258344da | ||
|
|
066b50ab9c | ||
|
|
4333e16626 | ||
|
|
d6e25dd60a | ||
|
|
23566681c1 | ||
|
|
ed39f7544c | ||
|
|
5d6b79aa4a | ||
|
|
59fb4c7452 |
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\AksesPasar;
|
||||
|
||||
enum PraktikFermentasi: string
|
||||
{
|
||||
case RUTIN_SENDIRI = 'Ya, rutin — dilakukan sendiri/individual';
|
||||
case RUTIN_KELOMPOK = 'Ya, rutin — bersama kelompok tani/kolektif';
|
||||
case PERNAH_SENDIRI = 'Pernah mencoba — sendiri';
|
||||
case PERNAH_KELOMPOK = 'Pernah mencoba — bersama kelompok';
|
||||
case BELUM_PERNAH = 'Belum pernah';
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return [
|
||||
['value' => self::RUTIN_SENDIRI->value, 'label' => 'Ya, rutin — dilakukan sendiri/individual'],
|
||||
['value' => self::RUTIN_KELOMPOK->value, 'label' => 'Ya, rutin — bersama kelompok tani/kolektif'],
|
||||
['value' => self::PERNAH_SENDIRI->value, 'label' => 'Pernah mencoba — sendiri'],
|
||||
['value' => self::PERNAH_KELOMPOK->value, 'label' => 'Pernah mencoba — bersama kelompok'],
|
||||
['value' => self::BELUM_PERNAH->value, 'label' => 'Belum pernah'],
|
||||
];
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\AksesPasar;
|
||||
|
||||
enum SaluranTerdahulu: string
|
||||
{
|
||||
case TENGKULAK = 'Tengkulak–pedagang lokal';
|
||||
case KOPERASI = 'Koperasi';
|
||||
case BUMDES = 'BUMDes';
|
||||
case LANGSUNG_PEMBELI = 'Langsung ke pembeli–eksportir';
|
||||
case LAINNYA = 'Lainnya';
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return [
|
||||
['value' => self::TENGKULAK->value, 'label' => 'Tengkulak–pedagang lokal'],
|
||||
['value' => self::KOPERASI->value, 'label' => 'Koperasi'],
|
||||
['value' => self::BUMDES->value, 'label' => 'BUMDes'],
|
||||
['value' => self::LANGSUNG_PEMBELI->value, 'label' => 'Langsung ke pembeli–eksportir'],
|
||||
['value' => self::LAINNYA->value, 'label' => 'Lainnya'],
|
||||
];
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\AksesPasar;
|
||||
|
||||
enum SkorKesadaranPremium: int
|
||||
{
|
||||
case BELUM_PERNAH_DENGAR = 1;
|
||||
case PERNAH_BELUM_PAHAM = 2;
|
||||
case PERNAH_SEDIKIT_PAHAM = 3;
|
||||
case SANGAT_PAHAM_BELUM_AKSES = 4;
|
||||
case SUDAH_AKSES_KONSISTEN = 5;
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return [
|
||||
['value' => self::BELUM_PERNAH_DENGAR->value, 'label' => 'Belum pernah dengar'],
|
||||
['value' => self::PERNAH_BELUM_PAHAM->value, 'label' => 'Pernah dengar tapi belum paham syarat'],
|
||||
['value' => self::PERNAH_SEDIKIT_PAHAM->value, 'label' => 'Pernah dengar & sedikit paham syarat'],
|
||||
['value' => self::SANGAT_PAHAM_BELUM_AKSES->value, 'label' => 'Sangat paham syarat tapi belum pernah akses'],
|
||||
['value' => self::SUDAH_AKSES_KONSISTEN->value, 'label' => 'Sudah akses & dapat harga premium konsisten'],
|
||||
];
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\AksesPasar;
|
||||
|
||||
enum SkorPengalaman: int
|
||||
{
|
||||
case BELUM_PERNAH = 1;
|
||||
case PERNAH_BERHENTI_TIDAK_ADA_AKSES = 2;
|
||||
case PERNAH_BERHENTI_MUNGKIN_KEMBALI = 3;
|
||||
case PERNAH_SESEKALI_JUAL = 4;
|
||||
case PERNAH_MASIH_AKTIF = 5;
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return [
|
||||
['value' => self::BELUM_PERNAH->value, 'label' => 'Belum pernah coba saluran lain'],
|
||||
['value' => self::PERNAH_BERHENTI_TIDAK_ADA_AKSES->value, 'label' => 'Pernah, sudah berhenti & tidak ada akses'],
|
||||
['value' => self::PERNAH_BERHENTI_MUNGKIN_KEMBALI->value, 'label' => 'Pernah, berhenti tapi masih mungkin kembali'],
|
||||
['value' => self::PERNAH_SESEKALI_JUAL->value, 'label' => 'Pernah & sesekali masih jual ke sana'],
|
||||
['value' => self::PERNAH_MASIH_AKTIF->value, 'label' => 'Pernah & masih punya akses aktif'],
|
||||
];
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum KeparahanSerangan: string
|
||||
{
|
||||
case RINGAN = 'ringan';
|
||||
case SEDANG = 'sedang';
|
||||
case BERAT = 'berat';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match($this) {
|
||||
self::RINGAN => 'Ringan, hanya beberapa tanaman',
|
||||
self::SEDANG => 'Sedang, sebagian tanaman terdampak',
|
||||
self::BERAT => 'Parah, sebagian besar tanaman terdampak',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,27 @@ namespace App\Enums;
|
||||
|
||||
enum KondisiTanaman: string
|
||||
{
|
||||
case PRODUKTIF = 'productive';
|
||||
case KURANG_PRODUKTIF = 'less_productive';
|
||||
case TIDAK_PRODUKTIF = 'not_productive';
|
||||
case SAKIT = 'sick';
|
||||
case MATI = 'dead';
|
||||
case BAIK = 'baik';
|
||||
case SEDANG = 'sedang';
|
||||
case BURUK = 'buruk';
|
||||
//case SAKIT= 'sakit';
|
||||
case MATI = 'mati';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match($this) {
|
||||
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',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum LayoutForm: string
|
||||
{
|
||||
case ROW = 'form-row';
|
||||
case COLUMN = 'form-column';
|
||||
case VALUE = 'form-value';
|
||||
case SECTION = 'form-section';
|
||||
case HR_LINE = 'form-hr-line';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match($this) {
|
||||
self::ROW => 'Row',
|
||||
self::COLUMN => 'Column',
|
||||
self::VALUE => 'Value',
|
||||
self::SECTION => 'Section',
|
||||
self::HR_LINE => 'HR Line',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
}
|
||||
@@ -19,13 +19,13 @@ enum Pendidikan: string
|
||||
{
|
||||
return match($this) {
|
||||
self::TIDAK_SEKOLAH => 'Tidak Sekolah',
|
||||
self::SD => 'SD atau Sederajat',
|
||||
self::SMP => 'SMP atau Sederajat',
|
||||
self::SMA => 'SMA atau Sederajat',
|
||||
self::SD => 'SD',
|
||||
self::SMP => 'SMP',
|
||||
self::SMA => 'SMA/SMK',
|
||||
self::DIPLOMA => 'Diploma 1-3 (D1-D3)',
|
||||
self::SARJANA => 'Sarjana (S1) atau sederajat',
|
||||
self::MAGISTER => 'Magister (S2) atau sederajat',
|
||||
self::DOKTOR => 'Doktor (S3) atau sederajat',
|
||||
self::SARJANA => 'Sarjana (S1)',
|
||||
self::MAGISTER => 'Magister (S2)',
|
||||
self::DOKTOR => 'Doktor (S3)',
|
||||
self::PESANTREN => 'Pesantren, Semiari, Wihara, atau Pendidikan Keagamaan Formal',
|
||||
self::LAINNYA => 'Lainnya',
|
||||
};
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\PendidikanPelatihan;
|
||||
|
||||
enum PelatihanGAP: string
|
||||
{
|
||||
case PEMANGKASAN = 'Pemangkasan atau perawatan tanaman';
|
||||
case PEMUPUKAN = 'Pemupukan atau nutrisi tanah';
|
||||
case PENGENDALIAN = 'Pengendalian hama dan penyakit';
|
||||
case PRAKTIK = 'Praktik Berkebun yang Baik (GAP)';
|
||||
case PENGOLAHAN = 'Pengolahan/pascapanen';
|
||||
case PENYERBUKAN = 'Penyerbukan manual (Vanili)';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum PenyakitTanaman: string
|
||||
{
|
||||
case BUSUK_BUAH = 'busuk_buah';
|
||||
case DAUN_MENGUNING = 'daun_menguning';
|
||||
case DAUN_BERCAK = 'daun_bercak';
|
||||
case TANAMAN_LAYU = 'tanaman_layu';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::BUSUK_BUAH => 'Busuk Buah',
|
||||
self::DAUN_MENGUNING => 'Daun Menguning',
|
||||
self::DAUN_BERCAK => 'Daun Bercak',
|
||||
self::TANAMAN_LAYU => 'Tanaman Layu',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\PraktikBudidaya;
|
||||
|
||||
enum Bulan: string
|
||||
{
|
||||
case JANUARI = 'Januari';
|
||||
case FEBRUARI = 'Februari';
|
||||
case MARET = 'Maret';
|
||||
case APRIL = 'April';
|
||||
case MEI = 'Mei';
|
||||
case JUNI = 'Juni';
|
||||
case JULI = 'Juli';
|
||||
case AGUSTUS = 'Agustus';
|
||||
case SEPTEMBER = 'September';
|
||||
case OKTOBER = 'Oktober';
|
||||
case NOVEMBER = 'November';
|
||||
case DESEMBER = 'Desember';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\PraktikBudidaya;
|
||||
|
||||
enum CaraSortasi: string
|
||||
{
|
||||
case DIPILAH = 'Dipilah manual dengan tangan (memilih satu per satu buah/biji yang bagus dan membuang yang rusak)';
|
||||
case ALAT_BANTU = 'Menggunakan alat bantu sederhana (tampah, ayakan, atau bak untuk memisahkan kotoran ringan)';
|
||||
case PERENDAMAN = 'Metode perendaman/tenggelam (memisahkan buah mengapung dan tenggelam)';
|
||||
case GRADING_KRITERIA = 'Grading berdasarkan kriteria (ukuran, warna, atau tingkat kematangan)';
|
||||
case PEMBERSIHAN = 'Hanya pembersihan kotoran kasar (membuang dahan atau sampah besar)';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match($this) {
|
||||
self::DIPILAH => 'Dipilah manual dengan tangan (memilih satu per satu buah/biji yang bagus dan membuang yang rusak)',
|
||||
self::ALAT_BANTU => 'Menggunakan alat bantu sederhana (tampah, ayakan, atau bak untuk memisahkan kotoran ringan)',
|
||||
self::PERENDAMAN => 'Metode perendaman/tenggelam (memisahkan buah mengapung dan tenggelam)',
|
||||
self::GRADING_KRITERIA => 'Grading berdasarkan kriteria (ukuran, warna, atau tingkat kematangan)',
|
||||
self::PEMBERSIHAN => 'Hanya pembersihan kotoran kasar (membuang dahan atau sampah besar)',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\PraktikBudidaya;
|
||||
|
||||
enum DasarPenentuanPanen: int
|
||||
{
|
||||
case KEBUTUHAN_UANG = 1;
|
||||
case UMUR_TANPA_KONDISI_BUAH = 2;
|
||||
case BUAH_JATUH = 3;
|
||||
case TINGKAT_KEPADATAN = 4;
|
||||
case WARNA_KULIT_BUAH = 5;
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match($this) {
|
||||
self::KEBUTUHAN_UANG => 'Kebutuhan uang mendesak, tanpa mempertimbangkan kematangan',
|
||||
self::UMUR_TANPA_KONDISI_BUAH => 'Umur/jadwal tetap, tanpa melihat kondisi buah langsung',
|
||||
self::BUAH_JATUH => 'Buah jatuh/matang pohon (sudah terlalu matang saat dipetik)',
|
||||
self::TINGKAT_KEPADATAN => 'Bersuara saat diketuk atau tingkat kepadatan buah',
|
||||
self::WARNA_KULIT_BUAH => 'Warna kulit buah (indikator paling akurat dan konsisten untuk menentukan kematangan optimal)',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\PraktikBudidaya;
|
||||
|
||||
enum EstimasiKehilanganHasil: string
|
||||
{
|
||||
case TIDAK_ADA = 'Tidak ada kehilangan';
|
||||
case SEDIKIT = 'Sedikit, sekitar 25 % dari total panen';
|
||||
case LUMAYAN = 'Lumayan, sekitar 50% dari total panen';
|
||||
case BANYAK = 'Banyak, sekitar 75% dari total panen';
|
||||
case HAMPIR_SEMUA = 'Hampir semua rusak, lebih dari 75%';
|
||||
case TIDAK_TAHU = 'Hanya pembersihan kotoran kasar (membuang dahan atau sampah besar)';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match($this) {
|
||||
self::TIDAK_ADA => 'Tidak ada kehilangan',
|
||||
self::SEDIKIT => 'Sedikit, sekitar 25 % dari total panen',
|
||||
self::LUMAYAN => 'Lumayan, sekitar 50% dari total panen',
|
||||
self::BANYAK => 'Banyak, sekitar 75% dari total panen',
|
||||
self::HAMPIR_SEMUA => 'Hampir semua rusak, lebih dari 75%',
|
||||
self::TIDAK_TAHU => 'Tidak tahu/sulit memperkirakan',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\PraktikBudidaya;
|
||||
|
||||
enum FrekuensiPemangkasanPendamping: string
|
||||
{
|
||||
case TIDAK_PERNAH = 'Tidak pernah memangkas sama sekali';
|
||||
case TIDAK_RUTIN = 'Memangkas, tapi tidak rutin dan tidak tahu tekniknya';
|
||||
case SATU_KALI_TAHUN = 'Memangkas 1 kali/tahun, tahu jenis tekniknya';
|
||||
case DUA_KALI_TAHUN = 'Memangkas 2 kali/tahun, tahu jenis tekniknya';
|
||||
case LEBIH_DUA_KALI_TAHUN = 'Memangkas lebih dari 2 kali/tahun dengan teknik yang tepat dan pohon penaung juga dipangkas rutin';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match($this) {
|
||||
self::TIDAK_PERNAH => 'Tidak pernah memangkas sama sekali',
|
||||
self::TIDAK_RUTIN => 'Memangkas, tapi tidak rutin dan tidak tahu tekniknya',
|
||||
self::SATU_KALI_TAHUN => 'Memangkas 1 kali/tahun, tahu jenis tekniknya',
|
||||
self::DUA_KALI_TAHUN => 'Memangkas 2 kali/tahun, tahu jenis tekniknya',
|
||||
self::LEBIH_DUA_KALI_TAHUN => 'Memangkas lebih dari 2 kali/tahun dengan teknik yang tepat dan pohon penaung juga dipangkas rutin',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\PraktikBudidaya;
|
||||
|
||||
enum FrekuensiPemangkasanUtama: int
|
||||
{
|
||||
case TIDAK_PERNAH = 1;
|
||||
case TIDAK_RUTIN = 2;
|
||||
case SATU_KALI_TAHUN = 3;
|
||||
case DUA_KALI_TAHUN = 4;
|
||||
case LEBIH_DUA_KALI_TAHUN = 5;
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match($this) {
|
||||
self::TIDAK_PERNAH => 'Tidak pernah memangkas sama sekali',
|
||||
self::TIDAK_RUTIN => 'Memangkas, tapi tidak rutin dan tidak tahu tekniknya',
|
||||
self::SATU_KALI_TAHUN => 'Memangkas 1 kali/tahun, tahu jenis tekniknya',
|
||||
self::DUA_KALI_TAHUN => 'Memangkas 2 kali/tahun, tahu jenis tekniknya',
|
||||
self::LEBIH_DUA_KALI_TAHUN => 'Memangkas lebih dari 2 kali/tahun dengan teknik yang tepat dan pohon penaung juga dipangkas rutin',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\PraktikBudidaya;
|
||||
|
||||
enum FrekuensiSanitasiLahan: int
|
||||
{
|
||||
case TIDAK_PERNAH = 1;
|
||||
case SESEKALI = 2;
|
||||
case SETIAP_PANEN = 3;
|
||||
case RUTIN_TIDAK_TERJADWAL = 4;
|
||||
case RUTIN_TERJADWAL = 5;
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match($this) {
|
||||
self::TIDAK_PERNAH => 'Tidak pernah',
|
||||
self::SESEKALI => 'Sesekali, tidak terjadwal',
|
||||
self::SETIAP_PANEN => 'Setiap panen, tapi tidak menyeluruh',
|
||||
self::RUTIN_TIDAK_TERJADWAL => 'Rutin, tapi tanpa jadwal yang jelas',
|
||||
self::RUTIN_TERJADWAL => 'Rutin terjadwal dan menyeluruh',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\PraktikBudidaya;
|
||||
|
||||
enum IntensitasSeranganHamaPenyakit: string
|
||||
{
|
||||
case RINGAN = 'Ringan - hanya beberapa tanaman terdampak';
|
||||
case SEDANG = 'Sedang - sebagian tanaman terdampak';
|
||||
case PARAH = 'Parah - sebagian besar tanaman terdampak';
|
||||
case BERVARIASI = 'Bervariasi - tergantung musim';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match($this) {
|
||||
self::RINGAN => 'Ringan - hanya beberapa tanaman terdampak',
|
||||
self::SEDANG => 'Sedang - sebagian tanaman terdampak',
|
||||
self::PARAH => 'Parah - sebagian besar tanaman terdampak',
|
||||
self::BERVARIASI => 'Bervariasi - tergantung musim',
|
||||
};
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => $case->value)->toArray();
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\PraktikBudidaya;
|
||||
|
||||
enum JenisPupuk: string
|
||||
{
|
||||
case TIDAK_MEMBERI = 'Tidak memberi pupuk';
|
||||
case ORGANIK = 'Pupuk organik (kompos/kandang)';
|
||||
case KIMIA = 'Pupuk kimia';
|
||||
case KEDUANYA = 'Keduanya';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match($this) {
|
||||
self::TIDAK_MEMBERI => 'Tidak memberi pupuk',
|
||||
self::ORGANIK => 'Pupuk organik (kompos/kandang)',
|
||||
self::KIMIA => 'Pupuk kimia',
|
||||
self::KEDUANYA => 'Keduanya',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\PraktikBudidaya;
|
||||
|
||||
enum KebutuhanAirPerMusim: string
|
||||
{
|
||||
case TIDAK_BUTUH = 'Tidak butuh, hujan cukup';
|
||||
case KURANG = 'Kurang, sering kekurangan air';
|
||||
case CUKUP = 'Cukup terpenuhi';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match($this) {
|
||||
self::TIDAK_BUTUH => 'Tidak butuh, hujan cukup',
|
||||
self::KURANG => 'Kurang, sering kekurangan air',
|
||||
self::CUKUP => 'Cukup terpenuhi',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\PraktikBudidaya;
|
||||
|
||||
enum KondisiPengelolaanAir: int
|
||||
{
|
||||
case KURANG_TIDAK_ADA_UPAYA = 1;
|
||||
case KURANG_TIDAK_SUDAH_BERUPAYA = 2;
|
||||
case CUKUP_DARI_HUJAN = 3;
|
||||
case CUKUP_IRIGASI_PINJAM = 4;
|
||||
case CUKUP_IRIGASI_SENDIRI = 5;
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match($this) {
|
||||
self::KURANG_TIDAK_ADA_UPAYA => 'Kebutuhan air kurang terpenuhi, sering kekurangan air, tidak ada upaya mengatasinya',
|
||||
self::KURANG_TIDAK_SUDAH_BERUPAYA => 'Kebutuhan air kurang terpenuhi, sering kekurangan air, tapi sudah mencoba mengandalkan sumber lain (sumur/sungai) walau belum cukup',
|
||||
self::CUKUP_DARI_HUJAN => 'Kebutuhan air cukup terpenuhi hanya dari hujan, tanpa sistem irigasi tambahan',
|
||||
self::CUKUP_IRIGASI_PINJAM => 'Kebutuhan air cukup terpenuhi, ada sistem irigasi tambahan (sungai/mata air/sumur) tapi pinjam',
|
||||
self::CUKUP_IRIGASI_SENDIRI => 'Kebutuhan air cukup terpenuhi, punya akses irigasi sendiri (sungai/mata air/sumur) yang dikelola baik',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\PraktikBudidaya;
|
||||
|
||||
enum MetodePenangananHamaPenyakit: int
|
||||
{
|
||||
case TIDAK_ADA = 1;
|
||||
case CARA_TRADISIONAL = 2;
|
||||
case PESTISIDA_SANITASI = 3;
|
||||
case KOMBINASI = 4;
|
||||
case PHT = 5;
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match($this) {
|
||||
self::TIDAK_ADA => 'Tidak ada penanganan',
|
||||
self::CARA_TRADISIONAL => 'Cara tradisional (doa/ritual)',
|
||||
self::PESTISIDA_SANITASI => 'Pestisida atau sanitasi',
|
||||
self::KOMBINASI => 'Kombinasi pestisada dan sanitasi',
|
||||
self::PHT => 'Pengendalian hama terpadu(PHT)',
|
||||
};
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => $case->value)->toArray();
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\PraktikBudidaya;
|
||||
|
||||
enum PemahamanManfaatKonservasi: string
|
||||
{
|
||||
case YA_PAHAM = 'Ya, tahu manfaatnya';
|
||||
case TIDAK_PAHAM = 'Dilakukan tapi tidak tahu manfaatnya, kebiasaan turun-temurun';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match($this) {
|
||||
self::YA_PAHAM => 'Ya, tahu manfaatnya',
|
||||
self::TIDAK_PAHAM => 'Dilakukan tapi tidak tahu manfaatnya, kebiasaan turun-temurun',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\PraktikBudidaya;
|
||||
|
||||
enum PemberianPupuk: int
|
||||
{
|
||||
case TIDAK_PERNAH = 1;
|
||||
case JENIS_DOSIS_WAKTU_TIDAK_MENENTU = 2;
|
||||
case JENIS_SESUAI_DOSIS_TIDAK_MENENTU = 3;
|
||||
case JENIS_DOSIS_SESUAI_WAKTU_CUKUP_TEPAT = 4;
|
||||
case JENIS_DOSIS_SESUAI_WAKTU_TEPAT = 5;
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match($this) {
|
||||
self::TIDAK_PERNAH => 'Tidak pernah memberi pupuk',
|
||||
self::JENIS_DOSIS_WAKTU_TIDAK_MENENTU => 'Memberi pupuk, tapi jenis/dosis tidak menentu, waktu sembarangan',
|
||||
self::JENIS_SESUAI_DOSIS_TIDAK_MENENTU => 'Memberi pupuk dengan jenis yang sesuai (organik/kimia/keduanya), tapi dosis atau waktu belum tepat',
|
||||
self::JENIS_DOSIS_SESUAI_WAKTU_CUKUP_TEPAT => 'Memberi pupuk dengan jenis dan dosis yang sesuai, waktu cukup tepat',
|
||||
self::JENIS_DOSIS_SESUAI_WAKTU_TEPAT => 'Memberi pupuk rutin dengan jenis tepat, dosis tepat, dan waktu tepat sesuai kebutuhan tanaman',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\PraktikBudidaya;
|
||||
|
||||
enum PenangananGulma: int
|
||||
{
|
||||
case DIBIARKAN = 1;
|
||||
case DICABUT = 2;
|
||||
case DISEMPROT = 3;
|
||||
case RUTIN_DICABUT_TANPA_JADWAL = 4;
|
||||
case RUTIN_TERJADWAL = 5;
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match($this) {
|
||||
self::DIBIARKAN => 'Dibiarkan saja, tidak pernah ditangani',
|
||||
self::DICABUT => 'Dicabut/dibersihkan sesekali, tidak terjadwal',
|
||||
self::DISEMPROT => 'Disemprot herbisida sesekali, tidak terjadwal',
|
||||
self::RUTIN_DICABUT_TANPA_JADWAL => 'Rutin dicabut/dipangkas, tapi tanpa jadwal yang jelas',
|
||||
self::RUTIN_TERJADWAL => 'Rutin terjadwal dengan metode yang konsisten (dicabut/dipangkas/dikelola sebagai mulsa)',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\PraktikBudidaya;
|
||||
|
||||
enum PenangananSisaBuahRanting: string
|
||||
{
|
||||
case DIBIARKAN = 'Dibiarkan di kebun';
|
||||
case DIKUMPULKAN = 'Dikumpulkan dan dibuang';
|
||||
case KOMPOS = 'Dijadikan kompos';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match($this) {
|
||||
self::DIBIARKAN => 'Dibiarkan di kebun',
|
||||
self::DIKUMPULKAN => 'Dikumpulkan dan dibuang',
|
||||
self::KOMPOS => 'Dijadikan kompos',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\PraktikBudidaya;
|
||||
|
||||
enum PenyerbukanManual: string
|
||||
{
|
||||
case SELALU = 'Selalu, setiap musim berbunga';
|
||||
case KADANG_KADANG = 'Kadang-kadang, tergantung kondisi';
|
||||
case TIDAK_PERNAH = 'Tidak pernah';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match($this) {
|
||||
self::SELALU => 'Selalu, setiap musim berbunga',
|
||||
self::KADANG_KADANG => 'Kadang-kadang, tergantung kondisi',
|
||||
self::TIDAK_PERNAH => 'Tidak pernah',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\PraktikBudidaya;
|
||||
|
||||
enum PraktikSortasi: int
|
||||
{
|
||||
case TIDAK_PERNAH = 1;
|
||||
case SANGAT_SEDERHANA = 2;
|
||||
case TIDAK_SETIAP_PANEN = 3;
|
||||
case SETIAP_PANEN = 4;
|
||||
case KETAT = 5;
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match($this) {
|
||||
self::TIDAK_PERNAH => 'Tidak pernah melakukan sortasi sama sekali',
|
||||
self::SANGAT_SEDERHANA => 'Sortasi sangat sederhana, hanya membuang yang jelas-jelas rusak/busuk',
|
||||
self::TIDAK_SETIAP_PANEN => 'Sortasi dilakukan tapi tidak setiap panen (kadang dilakukan, kadang tidak)',
|
||||
self::SETIAP_PANEN => 'Sortasi dilakukan setiap panen, tapi standarnya belum konsisten',
|
||||
self::KETAT => 'Sortasi ketat dengan standar yang jelas dan konsisten setiap panen',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\PraktikBudidaya;
|
||||
|
||||
enum TenagaKerja: string
|
||||
{
|
||||
case DIKERJAKAN_SENDIRI = 'Dikerjakan Sendiri';
|
||||
case DIBANTU_ANGGOTA_KELUARGA = 'Dibantu Anggota Keluarga';
|
||||
case UPAH_TENAGA_KERJA = 'Upah Tenaga Kerja';
|
||||
case GOTONG_ROYONG = 'Gotong Royong/Swadaya Komunitas';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match($this) {
|
||||
self::DIKERJAKAN_SENDIRI => 'Dikerjakan Sendiri',
|
||||
self::DIBANTU_ANGGOTA_KELUARGA => 'Dibantu Anggota Keluarga',
|
||||
self::UPAH_TENAGA_KERJA => 'Upah Tenaga Kerja',
|
||||
self::GOTONG_ROYONG => 'Gotong Royong/Swadaya Komunitas',
|
||||
};
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => $case->value)->toArray();
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\PraktikBudidaya;
|
||||
|
||||
enum TindakanPanenReject: string
|
||||
{
|
||||
case BUANG = 'Dibuang';
|
||||
case JUAL = 'Dijual ke tempat lain';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match($this) {
|
||||
self::BUANG => 'Dibuang',
|
||||
self::JUAL => 'Dijual ke tempat lain',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\PraktikBudidaya;
|
||||
|
||||
enum TingkatPanenReject: int
|
||||
{
|
||||
case SERING = 1;
|
||||
case CUKUP_SERING = 2;
|
||||
case KADANG = 3;
|
||||
case JARANG = 4;
|
||||
case TIDAK_ADA = 5;
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match($this) {
|
||||
self::SERING => 'Sering ditolak, lebih dari 50% hasil panen biasanya ditolak/tidak laku karena mutu',
|
||||
self::CUKUP_SERING => 'Cukup sering, sekitar 25–50% hasil panen ditolak/tidak laku',
|
||||
self::KADANG => 'Kadang ditolak, sekitar 10–25% hasil panen',
|
||||
self::JARANG => 'Jarang ditolak, kurang dari 10% hasil panen',
|
||||
self::TIDAK_ADA => 'Tidak ada yang ditolak, semua hasil panen sesuai standar pasar utama',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\PraktikBudidaya;
|
||||
|
||||
enum WaktuKemunculanTerparahHamaPenyakit: string
|
||||
{
|
||||
case HUJAN = 'Musim hujan';
|
||||
case KEMARAU = 'Musim kemarau';
|
||||
case SEPANJANG_TAHUN = 'Sepanjang tahun';
|
||||
case TIDAK_TENTU = 'Tidak tentu';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match($this) {
|
||||
self::HUJAN => 'Musim hujan',
|
||||
self::KEMARAU => 'Musim kemarau',
|
||||
self::SEPANJANG_TAHUN => 'Sepanjang tahun',
|
||||
self::TIDAK_TENTU => 'Tidak tentu',
|
||||
};
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => $case->value)->toArray();
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum SeranganHama: string
|
||||
{
|
||||
case ULAT = 'ulat';
|
||||
case BELALANG = 'belalang';
|
||||
case KUTU = 'kutu';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::ULAT => 'Ulat',
|
||||
self::BELALANG => 'Belalang',
|
||||
self::KUTU => 'Kutu',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\SosialEkonomi;
|
||||
|
||||
enum AlasanKreditDitolak: string
|
||||
{
|
||||
case TIDAK_PUNYA_JAMINAN_AGUNAN = 'tidak_punya_jaminan_agunan';
|
||||
case PROSES_TERLALU_RUMIT = 'proses_terlalu_rumit';
|
||||
case TAKUT_TIDAK_BISA_BAYAR = 'takut_tidak_bisa_bayar';
|
||||
case TIDAK_TAHU_CARANYA = 'tidak_tahu_caranya';
|
||||
case LAINNYA = 'lainnya';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::TIDAK_PUNYA_JAMINAN_AGUNAN => 'Tidak punya jaminan-agunan',
|
||||
self::PROSES_TERLALU_RUMIT => 'Proses terlalu rumit',
|
||||
self::TAKUT_TIDAK_BISA_BAYAR => 'Takut tidak bisa bayar',
|
||||
self::TIDAK_TAHU_CARANYA => 'Tidak tahu caranya',
|
||||
self::LAINNYA => 'Lainnya',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\SosialEkonomi;
|
||||
|
||||
enum BisaBeliPupukBersubsidi: string
|
||||
{
|
||||
case YA = 'ya';
|
||||
case TIDAK = 'tidak';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::YA => 'Ya',
|
||||
self::TIDAK => 'Tidak',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\SosialEkonomi;
|
||||
|
||||
enum JenisAsetProduktif: string
|
||||
{
|
||||
case TERNAK = 'ternak';
|
||||
case KENDARAAN = 'kendaraan';
|
||||
case ALAT_PERTANIAN = 'alat_pertanian';
|
||||
case LAINNYA = 'lainnya';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::TERNAK => 'Ternak',
|
||||
self::KENDARAAN => 'Kendaraan',
|
||||
self::ALAT_PERTANIAN => 'Alat pertanian',
|
||||
self::LAINNYA => 'Lainnya',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\SosialEkonomi;
|
||||
|
||||
enum KategoriPendapatanKomoditas: string
|
||||
{
|
||||
case UTAMA = 'utama';
|
||||
case LAINNYA = 'lainnya';
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\SosialEkonomi;
|
||||
|
||||
enum KeaktifanPertemuanKelompok: int
|
||||
{
|
||||
case TIDAK_PERNAH_HADIR = 1;
|
||||
case JARANG_HADIR = 2;
|
||||
case SERING_HADIR_LEBIH_BANYAK_DIAM = 3;
|
||||
case HAMPIR_SELALU_HADIR_KADANG_DISKUSI = 4;
|
||||
case SELALU_HADIR_AKTIF_DISKUSI = 5;
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::TIDAK_PERNAH_HADIR => 'Tidak pernah hadir',
|
||||
self::JARANG_HADIR => 'Jarang hadir',
|
||||
self::SERING_HADIR_LEBIH_BANYAK_DIAM => 'Sering hadir tapi lebih banyak diam',
|
||||
self::HAMPIR_SELALU_HADIR_KADANG_DISKUSI => 'Hampir selalu hadir & kadang diskusi',
|
||||
self::SELALU_HADIR_AKTIF_DISKUSI => 'Selalu hadir & aktif diskusi',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\SosialEkonomi;
|
||||
|
||||
enum KebebasanMemilihPembeli: int
|
||||
{
|
||||
case TIDAK_BEBAS_TERIKAT_SATU_PEMBELI = 1;
|
||||
case AGAK_TERIKAT_ADA_TEKANAN = 2;
|
||||
case AGAK_BEBAS_CENDERUNG_PEMBELI_SAMA = 3;
|
||||
case CUKUP_BEBAS_SESEKALI_PINDAH = 4;
|
||||
case SANGAT_BEBAS_PINDAH_KAPAN_SAJA = 5;
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::TIDAK_BEBAS_TERIKAT_SATU_PEMBELI => 'Tidak bebas, terikat satu pembeli',
|
||||
self::AGAK_TERIKAT_ADA_TEKANAN => 'Agak terikat, ada tekanan',
|
||||
self::AGAK_BEBAS_CENDERUNG_PEMBELI_SAMA => 'Agak bebas, cenderung pembeli sama',
|
||||
self::CUKUP_BEBAS_SESEKALI_PINDAH => 'Cukup bebas, sesekali pindah',
|
||||
self::SANGAT_BEBAS_PINDAH_KAPAN_SAJA => 'Sangat bebas, pindah kapan saja',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\SosialEkonomi;
|
||||
|
||||
enum KedekatanSesamaAnggota: string
|
||||
{
|
||||
case SANGAT_DEKAT = 'sangat_dekat';
|
||||
case CUKUP_DEKAT = 'cukup_dekat';
|
||||
case SEBATAS_KENAL = 'sebatas_kenal';
|
||||
case TIDAK_BEGITU_KENAL = 'tidak_begitu_kenal';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::SANGAT_DEKAT => 'Sangat dekat',
|
||||
self::CUKUP_DEKAT => 'Cukup dekat',
|
||||
self::SEBATAS_KENAL => 'Sebatas kenal',
|
||||
self::TIDAK_BEGITU_KENAL => 'Tidak begitu kenal',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\SosialEkonomi;
|
||||
|
||||
enum KemauanIkutProgram: int
|
||||
{
|
||||
case TIDAK_MAU = 1;
|
||||
case RAGU_RAGU = 2;
|
||||
case MAU_PERLU_DIPASTIKAN_MANFAAT = 3;
|
||||
case MAU_LIHAT_PROGRAM_DULU = 4;
|
||||
case MAU_LANGSUNG_IKUT = 5;
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::TIDAK_MAU => 'Tidak mau',
|
||||
self::RAGU_RAGU => 'Ragu-ragu',
|
||||
self::MAU_PERLU_DIPASTIKAN_MANFAAT => 'Mau, perlu dipastikan manfaatnya',
|
||||
self::MAU_LIHAT_PROGRAM_DULU => 'Mau, ingin lihat programnya dulu',
|
||||
self::MAU_LANGSUNG_IKUT => 'Mau, langsung ikut',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\SosialEkonomi;
|
||||
|
||||
enum KemauanMencobaPraktikBaru: int
|
||||
{
|
||||
case TIDAK_MAU = 1;
|
||||
case RAGU_RAGU = 2;
|
||||
case MAU_LIHAT_HASIL_DULU = 3;
|
||||
case MAU_LANGSUNG_COBA = 4;
|
||||
case MAU_COBA_SAMPAI_BERHASIL = 5;
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::TIDAK_MAU => 'Tidak mau',
|
||||
self::RAGU_RAGU => 'Ragu-ragu',
|
||||
self::MAU_LIHAT_HASIL_DULU => 'Mau, lihat hasil dulu',
|
||||
self::MAU_LANGSUNG_COBA => 'Mau langsung coba',
|
||||
self::MAU_COBA_SAMPAI_BERHASIL => 'Mau coba sampai berhasil',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\SosialEkonomi;
|
||||
|
||||
enum KeterikatanHutangPanen: int
|
||||
{
|
||||
case TIDAK_BERSEDIA_MENJAWAB = 0;
|
||||
case HUTANG_BESAR_HAMPIR_SELURUH_PANEN_TERIKAT = 1;
|
||||
case HUTANG_LEBIH_DARI_SEPARUH_PANEN_TERIKAT = 2;
|
||||
case HUTANG_SEBAGIAN_KECIL_TERIKAT = 3;
|
||||
case HUTANG_KECIL_TIDAK_MENGIKAT_PANEN = 4;
|
||||
case TIDAK_ADA = 5;
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::TIDAK_BERSEDIA_MENJAWAB => 'Tidak bersedia menjawab',
|
||||
self::HUTANG_BESAR_HAMPIR_SELURUH_PANEN_TERIKAT => 'Ada hutang besar, hampir seluruh panen terikat',
|
||||
self::HUTANG_LEBIH_DARI_SEPARUH_PANEN_TERIKAT => 'Ada hutang, >separuh panen terikat',
|
||||
self::HUTANG_SEBAGIAN_KECIL_TERIKAT => 'Ada hutang, sebagian kecil terikat',
|
||||
self::HUTANG_KECIL_TIDAK_MENGIKAT_PANEN => 'Ada hutang kecil, tidak mengikat panen',
|
||||
self::TIDAK_ADA => 'Tidak ada',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\SosialEkonomi;
|
||||
|
||||
enum KeterlibatanProgramKeuanganFormal: int
|
||||
{
|
||||
case TIDAK_PERNAH_MENERIMA = 1;
|
||||
case PERNAH_SATU_TIDAK_BERMANFAAT = 2;
|
||||
case SEDANG_MENERIMA_SATU = 3;
|
||||
case SEDANG_MENERIMA_LEBIH_DARI_SATU = 4;
|
||||
case AKTIF_BEBERAPA_PROGRAM_BERMANFAAT = 5;
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::TIDAK_PERNAH_MENERIMA => 'Tidak pernah menerima',
|
||||
self::PERNAH_SATU_TIDAK_BERMANFAAT => 'Pernah 1 program, tidak lagi & tidak bermanfaat',
|
||||
self::SEDANG_MENERIMA_SATU => 'Sedang menerima 1 program',
|
||||
self::SEDANG_MENERIMA_LEBIH_DARI_SATU => 'Sedang menerima >1 program',
|
||||
self::AKTIF_BEBERAPA_PROGRAM_BERMANFAAT => 'Aktif beberapa program & merasakan manfaat nyata',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\SosialEkonomi;
|
||||
|
||||
enum KondisiAsetProduktif: int
|
||||
{
|
||||
case TIDAK_ADA = 1;
|
||||
case ADA_SATU_KURANG_BAIK = 2;
|
||||
case ADA_SATU_BAIK = 3;
|
||||
case ADA_DUA_LEBIH_SEBAGIAN_KURANG_BAIK = 4;
|
||||
case ADA_DUA_LEBIH_SEMUA_BAIK = 5;
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::TIDAK_ADA => 'Tidak ada',
|
||||
self::ADA_SATU_KURANG_BAIK => 'Ada 1 jenis, kondisi kurang baik',
|
||||
self::ADA_SATU_BAIK => 'Ada 1 jenis, kondisi baik',
|
||||
self::ADA_DUA_LEBIH_SEBAGIAN_KURANG_BAIK => 'Ada 2+ jenis, sebagian kurang baik',
|
||||
self::ADA_DUA_LEBIH_SEMUA_BAIK => 'Ada 2+ jenis, semua kondisi baik',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\SosialEkonomi;
|
||||
|
||||
enum ManfaatKelompokTani: int
|
||||
{
|
||||
case TIDAK_ADA_MANFAAT = 1;
|
||||
case MANFAAT_SOSIAL_SAJA = 2;
|
||||
case SEDIKIT_MANFAAT_PRODUKSI_PEMASARAN = 3;
|
||||
case MANFAAT_CUKUP_TERASA = 4;
|
||||
case MANFAAT_NYATA_SIGNIFIKAN = 5;
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::TIDAK_ADA_MANFAAT => 'Tidak ada manfaat',
|
||||
self::MANFAAT_SOSIAL_SAJA => 'Manfaat sosial saja',
|
||||
self::SEDIKIT_MANFAAT_PRODUKSI_PEMASARAN => 'Sedikit manfaat produksi-pemasaran',
|
||||
self::MANFAAT_CUKUP_TERASA => 'Manfaat cukup terasa',
|
||||
self::MANFAAT_NYATA_SIGNIFIKAN => 'Manfaat nyata & signifikan',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\SosialEkonomi;
|
||||
|
||||
enum MinatPembeliHargaStabil: string
|
||||
{
|
||||
case MAU_HARGA_STABIL_LEBIH_PENTING = 'mau_harga_stabil_lebih_penting';
|
||||
case MAU_TAPI_INGIN_BANDINGKAN_DULU = 'mau_tapi_ingin_bandingkan_dulu';
|
||||
case RAGU_RAGU = 'ragu_ragu';
|
||||
case TIDAK_MAU_CARI_HARGA_TERBAIK = 'tidak_mau_cari_harga_terbaik';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::MAU_HARGA_STABIL_LEBIH_PENTING => 'Mau-harga stabil lebih penting',
|
||||
self::MAU_TAPI_INGIN_BANDINGKAN_DULU => 'Mau tapi ingin bandingkan dulu',
|
||||
self::RAGU_RAGU => 'Ragu-ragu',
|
||||
self::TIDAK_MAU_CARI_HARGA_TERBAIK => 'Tidak mau-cari harga terbaik tiap jual',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\SosialEkonomi;
|
||||
|
||||
enum OrientasiRencanaJangkaPanjang: int
|
||||
{
|
||||
case BELUM_KEPIKIRAN = 1;
|
||||
case INGIN_TETAP_SEPERTI_SEKARANG = 2;
|
||||
case INGIN_BERUBAH_BELUM_TAHU_CARANYA = 3;
|
||||
case INGIN_SUDAH_MULAI_DIPIKIRKAN = 4;
|
||||
case PUNYA_RENCANA_KONKRET = 5;
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::BELUM_KEPIKIRAN => 'Belum kepikiran',
|
||||
self::INGIN_TETAP_SEPERTI_SEKARANG => 'Ingin tetap seperti sekarang',
|
||||
self::INGIN_BERUBAH_BELUM_TAHU_CARANYA => 'Ada keinginan berubah tapi belum tahu caranya',
|
||||
self::INGIN_SUDAH_MULAI_DIPIKIRKAN => 'Ada keinginan & sudah mulai dipikirkan',
|
||||
self::PUNYA_RENCANA_KONKRET => 'Sudah punya rencana konkret',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\SosialEkonomi;
|
||||
|
||||
enum PanutanPetaniSukses: int
|
||||
{
|
||||
case TIDAK_ADA = 1;
|
||||
case ADA_DENGAR_DARI_ORANG_LAIN = 2;
|
||||
case TAHU_SIAPA_TIDAK_KENAL = 3;
|
||||
case KENAL_BELUM_DISKUSI = 4;
|
||||
case KENAL_PERNAH_DISKUSI_LANGSUNG = 5;
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::TIDAK_ADA => 'Tidak ada',
|
||||
self::ADA_DENGAR_DARI_ORANG_LAIN => 'Ada, dengar dari orang lain saja',
|
||||
self::TAHU_SIAPA_TIDAK_KENAL => 'Tahu siapa, tapi tidak kenal',
|
||||
self::KENAL_BELUM_DISKUSI => 'Kenal, belum pernah diskusi',
|
||||
self::KENAL_PERNAH_DISKUSI_LANGSUNG => 'Kenal & pernah diskusi langsung',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\SosialEkonomi;
|
||||
|
||||
enum PemahamanMutuHarga: int
|
||||
{
|
||||
case TIDAK_TAHU = 1;
|
||||
case PERNAH_DENGAR_TIDAK_YAKIN = 2;
|
||||
case TAHU_BEDA_BELUM_BUKTIKAN = 3;
|
||||
case TAHU_PERNAH_HARGA_LEBIH_TINGGI = 4;
|
||||
case TAHU_BETUL_BISA_JELASKAN_RINCI = 5;
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::TIDAK_TAHU => 'Tidak tahu',
|
||||
self::PERNAH_DENGAR_TIDAK_YAKIN => 'Pernah dengar, tidak yakin',
|
||||
self::TAHU_BEDA_BELUM_BUKTIKAN => 'Tahu ada beda, belum buktikan',
|
||||
self::TAHU_PERNAH_HARGA_LEBIH_TINGGI => 'Tahu & pernah dapat harga lebih tinggi',
|
||||
self::TAHU_BETUL_BISA_JELASKAN_RINCI => 'Tahu betul & bisa jelaskan rinci',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\SosialEkonomi;
|
||||
|
||||
enum PengalamanKreditKebun: int
|
||||
{
|
||||
case TIDAK_PERNAH_MENCOBA = 1;
|
||||
case PERNAH_COBA_DITOLAK = 2;
|
||||
case SEDANG_PROSES = 3;
|
||||
case BERHASIL_MASIH_PELUNASAN = 4;
|
||||
case BERHASIL_SUDAH_LUNAS = 5;
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::TIDAK_PERNAH_MENCOBA => 'Tidak pernah mencoba',
|
||||
self::PERNAH_COBA_DITOLAK => 'Pernah coba tapi ditolak',
|
||||
self::SEDANG_PROSES => 'Sedang dalam proses',
|
||||
self::BERHASIL_MASIH_PELUNASAN => 'Berhasil, masih proses pelunasan',
|
||||
self::BERHASIL_SUDAH_LUNAS => 'Berhasil & sudah lunas',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\SosialEkonomi;
|
||||
|
||||
enum PengetahuanHargaHasilOlah: string
|
||||
{
|
||||
case TIDAK_TAHU = 'tidak_tahu';
|
||||
case PERNAH_DENGAR_TIDAK_TAHU_PENGARUH = 'pernah_dengar_tidak_tahu_pengaruh';
|
||||
case TAHU_BEDA_HARGA_BELUM_COBA = 'tahu_beda_harga_belum_coba';
|
||||
case PERNAH_JUAL_HASIL_OLAH_HARGA_LEBIH_TINGGI = 'pernah_jual_hasil_olah_harga_lebih_tinggi';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::TIDAK_TAHU => 'Tidak tahu',
|
||||
self::PERNAH_DENGAR_TIDAK_TAHU_PENGARUH => 'Pernah dengar tapi tidak tahu pengaruh ke harga',
|
||||
self::TAHU_BEDA_HARGA_BELUM_COBA => 'Tahu ada beda harga tapi belum coba',
|
||||
self::PERNAH_JUAL_HASIL_OLAH_HARGA_LEBIH_TINGGI => 'Sudah pernah jual hasil olah dengan harga lebih tinggi',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\SosialEkonomi;
|
||||
|
||||
enum PeranDalamKelompok: int
|
||||
{
|
||||
case ANGGOTA_PASIF = 1;
|
||||
case ANGGOTA_BIASA_KADANG_DILIBATKAN = 2;
|
||||
case ANGGOTA_BIASA_CUKUP_AKTIF = 3;
|
||||
case PENGURUS_BELUM_BANYAK_TANGGUNG_JAWAB = 4;
|
||||
case KETUA_PENGURUS_AKTIF = 5;
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::ANGGOTA_PASIF => 'Anggota pasif',
|
||||
self::ANGGOTA_BIASA_KADANG_DILIBATKAN => 'Anggota biasa, kadang dilibatkan',
|
||||
self::ANGGOTA_BIASA_CUKUP_AKTIF => 'Anggota biasa, cukup aktif',
|
||||
self::PENGURUS_BELUM_BANYAK_TANGGUNG_JAWAB => 'Pengurus, belum banyak menjalankan tanggung jawab',
|
||||
self::KETUA_PENGURUS_AKTIF => 'Ketua-pengurus aktif & menjalankan tanggung jawab nyata',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\SosialEkonomi;
|
||||
|
||||
enum PeriodePendapatan: string
|
||||
{
|
||||
case MUSIM = 'musim';
|
||||
case TAHUN = 'tahun';
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\SosialEkonomi;
|
||||
|
||||
enum PernahBantuanNgoPerusahaan: string
|
||||
{
|
||||
case PERNAH = 'pernah';
|
||||
case TIDAK_PERNAH = 'tidak_pernah';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::PERNAH => 'Pernah',
|
||||
self::TIDAK_PERNAH => 'Tidak pernah',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\SosialEkonomi;
|
||||
|
||||
enum PernahJualHargaLebihTinggi: string
|
||||
{
|
||||
case BELUM_PERNAH = 'belum_pernah';
|
||||
case PERNAH = 'pernah';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::BELUM_PERNAH => 'Belum pernah',
|
||||
self::PERNAH => 'Pernah',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\SosialEkonomi;
|
||||
|
||||
enum PihakMembantuKonflik: string
|
||||
{
|
||||
case TIDAK_ADA_SELESAIKAN_SENDIRI = 'Tidak ada-selesaikan sendiri';
|
||||
case ADA = 'Ada';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\SosialEkonomi;
|
||||
|
||||
enum PinjamanTokohAdatPanen: string
|
||||
{
|
||||
case TIDAK_ADA = 'tidak_ada';
|
||||
case ADA = 'ada';
|
||||
case TIDAK_BERSEDIA_MENJAWAB = 'tidak_bersedia_menjawab';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::TIDAK_ADA => 'Tidak ada',
|
||||
self::ADA => 'Ada',
|
||||
self::TIDAK_BERSEDIA_MENJAWAB => 'Tidak bersedia menjawab',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\SosialEkonomi;
|
||||
|
||||
enum PraktikIjon: int
|
||||
{
|
||||
case TIDAK_BERSEDIA_MENJAWAB = 0;
|
||||
case HAMPIR_SELURUH_PANEN_TERIKAT = 1;
|
||||
case SEBAGIAN_BESAR_TERIKAT = 2;
|
||||
case SESEKALI_SEBAGIAN_KECIL = 3;
|
||||
case PERNAH_SUDAH_LAMA_TIDAK_LAGI = 4;
|
||||
case TIDAK_PERNAH = 5;
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::TIDAK_BERSEDIA_MENJAWAB => 'Tidak bersedia menjawab',
|
||||
self::HAMPIR_SELURUH_PANEN_TERIKAT => 'Hampir seluruh panen terikat ijon',
|
||||
self::SEBAGIAN_BESAR_TERIKAT => 'Sebagian besar terikat',
|
||||
self::SESEKALI_SEBAGIAN_KECIL => 'Sesekali-sebagian kecil',
|
||||
self::PERNAH_SUDAH_LAMA_TIDAK_LAGI => 'Pernah, sudah lama tidak lagi',
|
||||
self::TIDAK_PERNAH => 'Tidak pernah',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\SosialEkonomi;
|
||||
|
||||
enum SkorKecukupanPenghasilan: int
|
||||
{
|
||||
case SANGAT_TIDAK_CUKUP = 1;
|
||||
case KURANG_SERING_BERHUTANG = 2;
|
||||
case CUKUP_PAS_PASAN = 3;
|
||||
case CUKUP_ADA_SISA = 4;
|
||||
case LEBIH_DARI_CUKUP = 5;
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::SANGAT_TIDAK_CUKUP => 'Sangat tidak cukup',
|
||||
self::KURANG_SERING_BERHUTANG => 'Kurang, sering berhutang',
|
||||
self::CUKUP_PAS_PASAN => 'Cukup pas-pasan',
|
||||
self::CUKUP_ADA_SISA => 'Cukup, kadang ada sisa',
|
||||
self::LEBIH_DARI_CUKUP => 'Lebih dari cukup',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\SosialEkonomi;
|
||||
|
||||
enum SkorKejelasanStatusLahan: int
|
||||
{
|
||||
case TIDAK_ADA_DOKUMEN_ADA_SENGKETA = 1;
|
||||
case ADA_DOKUMEN_MASIH_SENGKETA = 2;
|
||||
case PERNAH_SENGKETA_SELESAI = 3;
|
||||
case LAHAN_ADAT_TANPA_SENGKETA = 4;
|
||||
case BERSERTIFIKAT_TANPA_SENGKETA = 5;
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::TIDAK_ADA_DOKUMEN_ADA_SENGKETA => 'Tidak ada dokumen & ada sengketa',
|
||||
self::ADA_DOKUMEN_MASIH_SENGKETA => 'Ada dokumen tapi masih sengketa',
|
||||
self::PERNAH_SENGKETA_SELESAI => 'Pernah sengketa, sudah selesai',
|
||||
self::LAHAN_ADAT_TANPA_SENGKETA => 'Lahan adat/keluarga/perhutanan sosial tanpa sengketa',
|
||||
self::BERSERTIFIKAT_TANPA_SENGKETA => 'Bersertifikat & tidak ada sengketa',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\SosialEkonomi;
|
||||
|
||||
enum SkorKemampuanMenabung: int
|
||||
{
|
||||
case TIDAK_BISA = 1;
|
||||
case PERNAH_TERPAKAI = 2;
|
||||
case KADANG_KADANG = 3;
|
||||
case BISA_TIDAK_TETAP = 4;
|
||||
case RUTIN_TETAP = 5;
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::TIDAK_BISA => 'Tidak bisa sama sekali',
|
||||
self::PERNAH_TERPAKAI => 'Pernah tapi selalu terpakai',
|
||||
self::KADANG_KADANG => 'Kadang-kadang',
|
||||
self::BISA_TIDAK_TETAP => 'Bisa tapi tidak tetap',
|
||||
self::RUTIN_TETAP => 'Rutin & jumlah tetap',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\SosialEkonomi;
|
||||
|
||||
enum SkorPeriodePaceklik: int
|
||||
{
|
||||
case LEBIH_DARI_EMPAT_BULAN = 1;
|
||||
case TIGA_SAMPAI_EMPAT_BULAN = 2;
|
||||
case SATU_SAMPAI_DUA_BULAN = 3;
|
||||
case SEBENTAR_TIDAK_MENENTU = 4;
|
||||
case TIDAK_ADA_STABIL = 5;
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::LEBIH_DARI_EMPAT_BULAN => '>4 bulan',
|
||||
self::TIGA_SAMPAI_EMPAT_BULAN => '3-4 bulan',
|
||||
self::SATU_SAMPAI_DUA_BULAN => '1-2 bulan',
|
||||
self::SEBENTAR_TIDAK_MENENTU => 'Sebentar & tidak menentu',
|
||||
self::TIDAK_ADA_STABIL => 'Tidak ada, stabil',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\SosialEkonomi;
|
||||
|
||||
enum StatusKartuTani: string
|
||||
{
|
||||
case BELUM_PUNYA = 'belum_punya';
|
||||
case SUDAH_PUNYA_BELUM_AKTIF = 'sudah_punya_belum_aktif';
|
||||
case SUDAH_PUNYA_AKTIF_DIGUNAKAN = 'sudah_punya_aktif_digunakan';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::BELUM_PUNYA => 'Belum punya',
|
||||
self::SUDAH_PUNYA_BELUM_AKTIF => 'Sudah punya tapi belum aktif',
|
||||
self::SUDAH_PUNYA_AKTIF_DIGUNAKAN => 'Sudah punya & aktif digunakan',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\SosialEkonomi;
|
||||
|
||||
enum StatusKepemilikanLahanSosialEkonomi: string
|
||||
{
|
||||
case MILIK_PRIBADI = 'Milik pribadi';
|
||||
case MILIK_ORANG_TUA_KELUARGA = 'Milik orang tua-keluarga';
|
||||
case SEWA_BAGI_HASIL = 'Sewa-bagi hasil';
|
||||
case LAHAN_ADAT = 'Lahan adat';
|
||||
case PERHUTANAN_SOSIAL = 'Perhutanan sosial';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\SosialEkonomi;
|
||||
|
||||
enum StatusKonflik: string
|
||||
{
|
||||
case SUDAH_SELESAI = 'Sudah selesai';
|
||||
case BELUM_MASIH_BERLANJUT = 'Belum, masih berlanjut';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\SosialEkonomi;
|
||||
|
||||
enum StatusProgramKeuanganFormal: string
|
||||
{
|
||||
case SEDANG_MENERIMA = 'sedang_menerima';
|
||||
case PERNAH_TAPI_TIDAK_LAGI = 'pernah_tapi_tidak_lagi';
|
||||
case BELUM_PERNAH = 'belum_pernah';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::SEDANG_MENERIMA => 'Sedang Menerima',
|
||||
self::PERNAH_TAPI_TIDAK_LAGI => 'Pernah tapi Tidak Lagi',
|
||||
self::BELUM_PERNAH => 'Belum Pernah',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\SosialEkonomi;
|
||||
|
||||
enum StatusRekeningTabungan: int
|
||||
{
|
||||
case TIDAK_PUNYA_REKENING = 1;
|
||||
case PUNYA_TIDAK_AKTIF = 2;
|
||||
case PUNYA_KADANG_DIGUNAKAN = 3;
|
||||
case PUNYA_CUKUP_RUTIN = 4;
|
||||
case AKTIF_RUTIN_DIGUNAKAN = 5;
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::TIDAK_PUNYA_REKENING => 'Tidak punya rekening',
|
||||
self::PUNYA_TIDAK_AKTIF => 'Punya tapi tidak aktif',
|
||||
self::PUNYA_KADANG_DIGUNAKAN => 'Punya, kadang digunakan',
|
||||
self::PUNYA_CUKUP_RUTIN => 'Punya, cukup rutin',
|
||||
self::AKTIF_RUTIN_DIGUNAKAN => 'Aktif & rutin digunakan',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\SosialEkonomi;
|
||||
|
||||
enum TekananJualSegera: string
|
||||
{
|
||||
case TIDAK_ADA = 'tidak_ada';
|
||||
case ADA = 'ada';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::TIDAK_ADA => 'Tidak ada',
|
||||
self::ADA => 'Ada',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\SosialEkonomi;
|
||||
|
||||
enum TerdaftarKelompokTani: string
|
||||
{
|
||||
case YA = 'ya';
|
||||
case TIDAK = 'tidak';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::YA => 'Ya',
|
||||
self::TIDAK => 'Tidak',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums\SosialEkonomi;
|
||||
|
||||
enum UsahaMutuTambahanHarga: string
|
||||
{
|
||||
case SEBANDING_COCOK_DICOBA = 'sebanding_cocok_dicoba';
|
||||
case TIDAK_YAKIN = 'tidak_yakin';
|
||||
case TIDAK_SEBANDING_TERLALU_BANYAK_USAHA = 'tidak_sebanding_terlalu_banyak_usaha';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::SEBANDING_COCOK_DICOBA => 'Sebanding-cocok dicoba',
|
||||
self::TIDAK_YAKIN => 'Tidak yakin',
|
||||
self::TIDAK_SEBANDING_TERLALU_BANYAK_USAHA => 'Tidak sebanding-terlalu banyak usaha',
|
||||
};
|
||||
}
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->map(fn ($case) => [
|
||||
'value' => $case->value,
|
||||
'label' => $case->label(),
|
||||
])->toArray();
|
||||
}
|
||||
|
||||
public static function values(): array
|
||||
{
|
||||
return array_column(self::cases(), 'value');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\Core;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
||||
use App\Models\Core\Program;
|
||||
use App\Http\Resources\Core\ProgramResource;
|
||||
|
||||
class ProgramController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index(Request $request): AnonymousResourceCollection
|
||||
{
|
||||
$perPage = $request->query('per_page', 10);
|
||||
$search = $request->query('search', '');
|
||||
|
||||
$program = Program::where('nama', 'like', "%$search%")
|
||||
->paginate($perPage);
|
||||
|
||||
return ProgramResource::collection($program);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(string $id): ProgramResource
|
||||
{
|
||||
$program = Program::findOrFail($id);
|
||||
return new ProgramResource($program);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\Ekosistem;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
use App\Models\Ekosistem\TabelBasisData;
|
||||
use App\Models\Ekosistem\KolomBasisData;
|
||||
use App\Models\Core\Program;
|
||||
|
||||
|
||||
class FormBasisDataController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index(Request $request, string $tabelId): JsonResponse
|
||||
{
|
||||
if (!Gate::any(['super_admin', 'admin', 'fasilitator'])) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$tabel = TabelBasisData::with('kolom')
|
||||
->whereHas('kolom', function ($query) {
|
||||
$query->where('is_active', true);
|
||||
})->find($tabelId);
|
||||
if (!$tabel) {
|
||||
abort(404, 'Data tabel tidak ditemukan.');
|
||||
}
|
||||
$kolom = KolomBasisData::where('tabel_id', $tabelId)
|
||||
->where('is_active', true)->get();
|
||||
if ($kolom->isEmpty()) {
|
||||
abort(404, 'Data kolom tidak ditemukan untuk tabel ini.');
|
||||
}
|
||||
|
||||
$program = null;
|
||||
if (app()->has('SystemProgram')) {
|
||||
$program = app('SystemProgram');
|
||||
} else {
|
||||
if ($request->has('program_id') && $request->query('program_id')) {
|
||||
$programId = $request->query('program_id');
|
||||
$program = Program::find($programId);
|
||||
}
|
||||
}
|
||||
if (!$program) {
|
||||
abort(400, 'Program tidak ditemukan.');
|
||||
}
|
||||
|
||||
$method = $request->query('method', 'add');
|
||||
|
||||
$list_relasi = null;
|
||||
if ($method == 'add' || $method == 'edit') {
|
||||
$list_relasi = [];
|
||||
foreach ($kolom as $k) {
|
||||
if ($k->tipe == 'foreign_key') {
|
||||
$relasi['kolom_id'] = $k->id;
|
||||
try {
|
||||
$options_kolom = DB::table($k->relasi_tabel)->selectRaw($k->relasi_kolom_label . ' as label, ' . $k->relasi_kolom_id . ' as value')->whereNull('deleted_at');
|
||||
$relasi['options'] = $options_kolom->get();
|
||||
$relasi['sql'] = $options_kolom->toSql();
|
||||
} catch (\Throwable $th) {
|
||||
$relasi['options'] = [];
|
||||
}
|
||||
$list_relasi[] = $relasi;
|
||||
}
|
||||
}
|
||||
$list_relasi = collect($list_relasi);
|
||||
} elseif ($method == 'view') {
|
||||
$id = $request->query('value_id');
|
||||
if (!$id) {
|
||||
abort(400, 'value_id query parameter diperlukan untuk view method.');
|
||||
}
|
||||
|
||||
$values = ValueBasisData::query()
|
||||
->where('tabel_id', $tabelId)
|
||||
->where('value_id', $id)
|
||||
->where('program_id', $program->id)
|
||||
->get();
|
||||
if ($values->isEmpty()) {
|
||||
abort(404, 'Data tidak ditemukan.');
|
||||
}
|
||||
|
||||
foreach ($values as $v) {
|
||||
$k = $kolom->where('id', $v->kolom_id)->first();
|
||||
if ($k->tipe == 'foreign_key') {
|
||||
$v->value_relasi_label = DB::table($k->relasi_tabel)->where($k->relasi_kolom_id, $v->value_relasi)->value($k->relasi_kolom_label);
|
||||
} else if ($k->tipe == 'enum') {
|
||||
$opsi = collect($k->enum_opsi);
|
||||
$found = $opsi->first(function ($item) use ($v) {
|
||||
return (string) $item['value'] === (string) $v->value_enum;
|
||||
});
|
||||
$v->value_enum_label = $found['label'] ?? null;
|
||||
}
|
||||
}
|
||||
|
||||
$value_id = $id;
|
||||
}
|
||||
|
||||
|
||||
$errors = $request->query('errors', null);
|
||||
|
||||
return response()->json($tabel->renderHtml($method, $errors, $list_relasi));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\Ekosistem;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
use App\Models\Ekosistem\TabelBasisData;
|
||||
|
||||
use App\Http\Resources\Ekosistem\TabelBasisDataResource;
|
||||
|
||||
class TabelBasisDataController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index(Request $request): AnonymousResourceCollection
|
||||
{
|
||||
if (!Gate::any(['super_admin', 'admin', 'fasilitator'])) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$perPage = $request->query('per_page', 10);
|
||||
$search = strtolower($request->query('search', ''));
|
||||
|
||||
$tabel = TabelBasisData::with('kolom')
|
||||
->whereHas('kolom', function ($query) {
|
||||
$query->where('is_active', true);
|
||||
})
|
||||
->whereRaw('lower(tabel) LIKE ?', ["%$search%"])
|
||||
->paginate($perPage);
|
||||
|
||||
return TabelBasisDataResource::collection($tabel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(Request $request, string $id): JsonResponse
|
||||
{
|
||||
if (!Gate::any(['super_admin', 'admin', 'fasilitator'])) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$tabel = TabelBasisData::with('kolom', 'form', 'form.form', 'form.form.form', 'form.form.form.kolom')->findOrFail($id);
|
||||
|
||||
return (new TabelBasisDataResource($tabel))
|
||||
->response();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,402 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\Ekosistem;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
use App\Models\Ekosistem\TabelBasisData;
|
||||
use App\Models\Ekosistem\KolomBasisData;
|
||||
use App\Models\Ekosistem\ValueBasisData;
|
||||
use App\Models\Core\Program;
|
||||
|
||||
class ValueBasisDataController extends Controller
|
||||
{
|
||||
|
||||
public function index(Request $request, string $tabelId): JsonResponse
|
||||
{
|
||||
if (!Gate::any(['super_admin', 'admin', 'fasilitator'])) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$perPage = $request->query('per_page', 10);
|
||||
$search = strtolower($request->query('search', ''));
|
||||
|
||||
$program = null;
|
||||
$programList = Program::get();
|
||||
if (app()->has('SystemProgram')) {
|
||||
$program = app('SystemProgram');
|
||||
} else {
|
||||
if ($request->has('program_id') && $request->query('program_id')) {
|
||||
$programId = $request->query('program_id');
|
||||
$program = Program::find($programId);
|
||||
if (!$program) {
|
||||
abort(400, 'Program tidak ditemukan.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$tabel = TabelBasisData::with('kolom')
|
||||
->whereHas('kolom', function ($query) {
|
||||
$query->where('is_active', true);
|
||||
})
|
||||
->find($tabelId);
|
||||
if (!$tabel) {
|
||||
abort(404, 'Data tabel tidak ditemukan.');
|
||||
}
|
||||
$kolom = KolomBasisData::where('tabel_id', $tabelId)
|
||||
->where('is_active', true)
|
||||
->when('is_browse', function ($q) {
|
||||
$q->where('is_browse', true);
|
||||
})
|
||||
->orderBy('urutan', 'asc')
|
||||
->get();
|
||||
if ($kolom->isEmpty()) {
|
||||
abort(404, 'Data kolom tidak ditemukan untuk tabel ini.');
|
||||
}
|
||||
|
||||
$selects = [];
|
||||
foreach ($kolom as $k) {
|
||||
if ($k->tipe == 'boolean') {
|
||||
$selects[] = "
|
||||
MAX(
|
||||
CASE
|
||||
WHEN kolom_id = {$k->id}
|
||||
THEN CASE
|
||||
WHEN value_boolean = true THEN 'Ya'
|
||||
WHEN value_boolean = false THEN 'Tidak'
|
||||
ELSE NULL
|
||||
END
|
||||
ELSE NULL
|
||||
END
|
||||
) AS \"{$k->kolom}\"
|
||||
";
|
||||
} elseif ($k->tipe == 'foreign_key') {
|
||||
$selects[] = "
|
||||
MAX(
|
||||
CASE
|
||||
WHEN kolom_id = {$k->id}
|
||||
THEN (select {$k->relasi_kolom_label} from {$k->relasi_tabel} where {$k->relasi_kolom_id} = value_relasi)
|
||||
ELSE NULL
|
||||
END
|
||||
) AS \"{$k->kolom}\"
|
||||
";
|
||||
} elseif ($k->tipe == 'enum') {
|
||||
$selects[] = "
|
||||
MAX(
|
||||
CASE
|
||||
WHEN kolom_id = {$k->id}
|
||||
AND value_enum IS NOT NULL
|
||||
THEN (
|
||||
SELECT elem->>'label'
|
||||
FROM ekosistem_basis_data_kolom k,
|
||||
jsonb_array_elements(k.enum_opsi::jsonb) AS elem
|
||||
WHERE k.id = kolom_id
|
||||
AND elem->>'value' = value_enum
|
||||
LIMIT 1
|
||||
)
|
||||
ELSE NULL
|
||||
END
|
||||
) AS \"{$k->kolom}\"
|
||||
";
|
||||
} else {
|
||||
$selects[] = "
|
||||
MAX(
|
||||
CASE
|
||||
WHEN kolom_id = {$k->id}
|
||||
THEN value_{$k->tipe}
|
||||
ELSE NULL
|
||||
END
|
||||
) AS \"{$k->kolom}\"
|
||||
";
|
||||
}
|
||||
}
|
||||
|
||||
$base = ValueBasisData::query()
|
||||
->join('core_program', 'core_program.id', '=', 'ekosistem_basis_data_value.program_id')
|
||||
->where('tabel_id', $tabelId)
|
||||
->when($program, function ($query) use ($program) {
|
||||
$query->where('program_id', $program->id);
|
||||
})
|
||||
->selectRaw("
|
||||
core_program.id AS program_id,
|
||||
core_program.nama AS program_nama,
|
||||
tabel_id,
|
||||
value_id,
|
||||
" . implode(",\n", $selects) . "
|
||||
")
|
||||
->groupBy('core_program.id', 'core_program.nama', 'tabel_id', 'value_id')
|
||||
->orderBy('value_id', 'asc');
|
||||
|
||||
$values = DB::query()->fromSub($base, 'pivot')
|
||||
->when($search, function ($query) use ($search, $kolom) {
|
||||
$query->where(function ($q) use ($search, $kolom) {
|
||||
foreach ($kolom as $k) {
|
||||
if ($k->tipe == 'text' || $k->tipe == 'varchar') {
|
||||
$q->orWhereRaw("lower({$k->kolom}) LIKE ?", ["%$search%"]);
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
->paginate($perPage);
|
||||
|
||||
return response()->json($values);
|
||||
}
|
||||
|
||||
private function prepareValidationRules($kolom)
|
||||
{
|
||||
$rules = [];
|
||||
foreach ($kolom as $k) {
|
||||
if ($k->validasi && is_array($k->validasi)) {
|
||||
$rules[$k->kolom] = $k->validasi;
|
||||
|
||||
if (!in_array('required', $k->validasi) && !in_array('nullable', $k->validasi)) {
|
||||
$rules[$k->kolom][] = 'nullable';
|
||||
}
|
||||
|
||||
if (!in_array('string', $k->validasi) && ($k->tipe == 'varchar' || $k->tipe == 'text')) {
|
||||
$rules[$k->kolom][] = 'string';
|
||||
}
|
||||
if (!in_array('max', $k->validasi) && ($k->tipe == 'varchar')) {
|
||||
$rules[$k->kolom][] = 'max:255';
|
||||
}
|
||||
if (!in_array('integer', $k->validasi) && $k->tipe == 'integer') {
|
||||
$rules[$k->kolom][] = 'integer';
|
||||
}
|
||||
if (!in_array('boolean', $k->validasi) && $k->tipe == 'boolean') {
|
||||
$rules[$k->kolom][] = 'boolean';
|
||||
}
|
||||
if (!in_array('date', $k->validasi) && ($k->tipe == 'date' || $k->tipe == 'datetime')) {
|
||||
$rules[$k->kolom][] = 'date';
|
||||
}
|
||||
if ($k->tipe == 'foreign_key') {
|
||||
$rules[$k->kolom][] = 'exists:' . $k->relasi_tabel . ',' . $k->relasi_kolom_id;
|
||||
}
|
||||
if ($k->tipe == 'enum') {
|
||||
$enumValues = collect($k->enum_opsi)->pluck('value')->toArray();
|
||||
$rules[$k->kolom][] = Rule::in($enumValues);
|
||||
}
|
||||
|
||||
} else {
|
||||
$rules[$k->kolom] = ['nullable'];
|
||||
|
||||
if ($k->tipe == 'varchar' || $k->tipe == 'text') {
|
||||
$rules[$k->kolom][] = 'string';
|
||||
}
|
||||
if ($k->tipe == 'varchar') {
|
||||
$rules[$k->kolom][] = 'max:255';
|
||||
}
|
||||
if ($k->tipe == 'integer') {
|
||||
$rules[$k->kolom][] = 'integer';
|
||||
}
|
||||
if ($k->tipe == 'boolean') {
|
||||
$rules[$k->kolom][] = 'boolean';
|
||||
}
|
||||
if ($k->tipe == 'date' || $k->tipe == 'datetime') {
|
||||
$rules[$k->kolom][] = 'date';
|
||||
}
|
||||
if ($k->tipe == 'foreign_key') {
|
||||
$rules[$k->kolom][] = 'exists:' . $k->relasi_tabel . ',' . $k->relasi_kolom_id;
|
||||
}
|
||||
if ($k->tipe == 'enum') {
|
||||
$enumValues = collect($k->enum_opsi)->pluck('value')->toArray();
|
||||
$rules[$k->kolom][] = Rule::in($enumValues);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $rules;
|
||||
}
|
||||
|
||||
public function store(Request $request, string $tabelId): JsonResponse
|
||||
{
|
||||
if (!Gate::any(['super_admin', 'admin', 'fasilitator'])) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$tabel = TabelBasisData::whereHas('kolom', function ($query) {
|
||||
$query->where('is_active', true);
|
||||
})->find($tabelId);
|
||||
if (!$tabel) {
|
||||
abort(404, 'Data tabel tidak ditemukan.');
|
||||
}
|
||||
$kolom = KolomBasisData::where('tabel_id', $tabelId)
|
||||
->where('is_active', true)->get();
|
||||
if ($kolom->isEmpty()) {
|
||||
abort(404, 'Data kolom tidak ditemukan untuk tabel ini.');
|
||||
}
|
||||
if (app()->has('SystemProgram')) {
|
||||
$program = app('SystemProgram');
|
||||
} else {
|
||||
if ($request->has('program_id') && $request->query('program_id')) {
|
||||
$programId = $request->query('program_id');
|
||||
$program = Program::find($programId);
|
||||
if (!$program) {
|
||||
abort(400, 'Program tidak ditemukan.');
|
||||
}
|
||||
} else {
|
||||
abort(400, 'Program tidak ditemukan.');
|
||||
}
|
||||
}
|
||||
|
||||
$validated = $request->validate($this->prepareValidationRules($kolom));
|
||||
|
||||
DB::transaction(function () use ($program, $tabelId, $validated, $kolom) {
|
||||
$maxId = ValueBasisData::where('tabel_id', $tabelId)
|
||||
->where('program_id', $program->id)
|
||||
->whereNotNull('value_id')
|
||||
->max('value_id');
|
||||
foreach ($kolom as $k) {
|
||||
$values = [
|
||||
'program_id' => $program->id,
|
||||
'tabel_id' => (int)$tabelId,
|
||||
'kolom_id' => $k->id,
|
||||
'value_id' => ($maxId ?? 0) + 1,
|
||||
'created_by' => auth()->id(),
|
||||
'updated_by' => auth()->id(),
|
||||
];
|
||||
if ($k->tipe == 'foreign_key') {
|
||||
$values['value_relasi'] = $validated[$k->kolom] ?? null;
|
||||
} else {
|
||||
$values['value_' . $k->tipe] = $validated[$k->kolom] ?? null;
|
||||
}
|
||||
|
||||
ValueBasisData::create($values);
|
||||
}
|
||||
});
|
||||
|
||||
return response()->json(['message' => 'Data berhasil disimpan.']);
|
||||
}
|
||||
|
||||
public function show(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function update(Request $request, string $tabelId, string $id): JsonResponse
|
||||
{
|
||||
if (!Gate::any(['super_admin', 'admin', 'fasilitator'])) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$tabel = TabelBasisData::whereHas('kolom', function ($query) {
|
||||
$query->where('is_active', true);
|
||||
})->find($tabelId);
|
||||
if (!$tabel) {
|
||||
abort(404, 'Data tabel tidak ditemukan.');
|
||||
}
|
||||
$kolom = KolomBasisData::where('tabel_id', $tabelId)
|
||||
->where('is_active', true)->get();
|
||||
if ($kolom->isEmpty()) {
|
||||
abort(404, 'Data kolom tidak ditemukan untuk tabel ini.');
|
||||
}
|
||||
if (app()->has('SystemProgram')) {
|
||||
$program = app('SystemProgram');
|
||||
} else {
|
||||
if ($request->has('program_id') && $request->query('program_id')) {
|
||||
$programId = $request->query('program_id');
|
||||
$program = Program::find($programId);
|
||||
if (!$program) {
|
||||
abort(400, 'Program tidak ditemukan.');
|
||||
}
|
||||
} else {
|
||||
abort(400, 'Program tidak ditemukan.');
|
||||
}
|
||||
}
|
||||
|
||||
$values = ValueBasisData::query()
|
||||
->where('tabel_id', $tabelId)
|
||||
->where('value_id', $id)
|
||||
->where('program_id', $program->id)
|
||||
->get();
|
||||
if ($values->isEmpty()) {
|
||||
abort(404, 'Data tidak ditemukan.');
|
||||
}
|
||||
|
||||
$validated = $request->validate($this->prepareValidationRules($kolom));
|
||||
|
||||
DB::transaction(function () use ($program, $tabelId, $validated, $kolom, $id, $values) {
|
||||
foreach ($validated as $kol => $val) {
|
||||
$k = $kolom->where('kolom', $kol)->first();
|
||||
if (!$k) {
|
||||
continue;
|
||||
}
|
||||
$v = $values->where('kolom_id', $k->id)->first();
|
||||
if (!$v) {
|
||||
$vals = [
|
||||
'program_id' => $program->id,
|
||||
'tabel_id' => (int)$tabelId,
|
||||
'kolom_id' => $k->id,
|
||||
'value_id' => $id,
|
||||
'created_by' => auth()->id(),
|
||||
'updated_by' => auth()->id(),
|
||||
];
|
||||
if ($k->tipe == 'foreign_key') {
|
||||
$vals['value_relasi'] = $validated[$k->kolom] ?? null;
|
||||
} else {
|
||||
$vals['value_' . $k->tipe] = $validated[$k->kolom] ?? null;
|
||||
}
|
||||
ValueBasisData::create($vals);
|
||||
} else {
|
||||
$v->update([
|
||||
'value_' . ($k->tipe == 'foreign_key' ? 'relasi' : $k->tipe) => $val,
|
||||
'updated_by' => auth()->id(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return response()->json(['message' => 'Data berhasil diperbarui.']);
|
||||
}
|
||||
|
||||
public function destroy(Request $request, string $tabelId, string $id): JsonResponse
|
||||
{
|
||||
if (!Gate::any(['super_admin', 'admin', 'fasilitator'])) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$tabel = TabelBasisData::whereHas('kolom', function ($query) {
|
||||
$query->where('is_active', true);
|
||||
})->find($tabelId);
|
||||
if (!$tabel) {
|
||||
abort(404, 'Data tabel tidak ditemukan.');
|
||||
}
|
||||
$kolom = KolomBasisData::where('tabel_id', $tabelId)->get();
|
||||
if ($kolom->isEmpty()) {
|
||||
abort(404, 'Data kolom tidak ditemukan untuk tabel ini.');
|
||||
}
|
||||
if (app()->has('SystemProgram')) {
|
||||
$program = app('SystemProgram');
|
||||
} else {
|
||||
if ($request->has('program_id') && $request->query('program_id')) {
|
||||
$programId = $request->query('program_id');
|
||||
$program = Program::find($programId);
|
||||
if (!$program) {
|
||||
abort(400, 'Program tidak ditemukan.');
|
||||
}
|
||||
} else {
|
||||
abort(400, 'Program tidak ditemukan.');
|
||||
}
|
||||
}
|
||||
|
||||
$values = ValueBasisData::query()
|
||||
->where('tabel_id', $tabelId)
|
||||
->where('value_id', $id)
|
||||
->where('program_id', $program->id)
|
||||
->get();
|
||||
if ($values->isEmpty()) {
|
||||
abort(404, 'Data tidak ditemukan.');
|
||||
}
|
||||
|
||||
ValueBasisData::query()
|
||||
->where('tabel_id', $tabelId)
|
||||
->where('value_id', $id)
|
||||
->where('program_id', $program->id)
|
||||
->delete();
|
||||
|
||||
return response()->json(['message' => 'Data berhasil dihapus.']);
|
||||
}
|
||||
}
|
||||
+22
-21
@@ -1,21 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
namespace App\Http\Controllers\Api\Konfigurasi;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Profile;
|
||||
|
||||
use App\Http\Resources\UserResource;
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
public function login(Request $request): JSONResponse
|
||||
public function login(Request $request): JsonResponse
|
||||
{
|
||||
$credentials = $request->validate([
|
||||
'email' => ['required', 'email'],
|
||||
@@ -29,6 +27,13 @@ class AuthController extends Controller
|
||||
}
|
||||
|
||||
$user = Auth::user();
|
||||
|
||||
if ($user->status === 'pending') {
|
||||
return response()->json([
|
||||
'message' => 'Akun Anda masih berstatus pending. Silakan tunggu verifikasi dari Super Admin.'
|
||||
], 403);
|
||||
}
|
||||
|
||||
$user->tokens()->delete();
|
||||
|
||||
$token = $user->createToken('mobile-token')->plainTextToken;
|
||||
@@ -39,46 +44,42 @@ class AuthController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function signup(Request $request): JSONResponse
|
||||
public function signup(Request $request): JsonResponse
|
||||
{
|
||||
$credentials = $request->validate([
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'email' => ['required', 'email', 'max:255', 'unique:users'],
|
||||
'password' => ['required', 'string', 'min:8', 'confirmed'],
|
||||
'role' => ['string'],
|
||||
'username' => ['required', 'string', 'max:255'],
|
||||
'uid' => ['required','string', 'unique:users'],
|
||||
]);
|
||||
|
||||
$user = User::create([
|
||||
'name' => $credentials['name'],
|
||||
'email' => $credentials['email'],
|
||||
'password' => Hash::make($credentials['password']),
|
||||
'role' => $credentials['role'],
|
||||
'username' => $credentials['username'],
|
||||
'uid' => $credentials['uid'],
|
||||
'role' => null,
|
||||
'status' => 'pending',
|
||||
]);
|
||||
|
||||
$profile = Profile::create([
|
||||
'nama' => $credentials['name'],
|
||||
'email' => $credentials['email'],
|
||||
'role' => $credentials['role'],
|
||||
'user_uid' => $credentials['uid'],
|
||||
'user_id' => $user->id,
|
||||
'created_by' => $user->id,
|
||||
'updated_by' => $user->id,
|
||||
|
||||
|
||||
'role' => null,
|
||||
]);
|
||||
|
||||
if (!Auth::attempt($credentials)) {
|
||||
return response()->json([
|
||||
'message' => 'Email dan/atau password tidak sesuai'
|
||||
], 401);
|
||||
}
|
||||
|
||||
$user = Auth::user();
|
||||
$user->tokens()->delete();
|
||||
|
||||
$token = $user->createToken('mobile-token')->plainTextToken;
|
||||
|
||||
return response()->json([
|
||||
'access_token' => $token,
|
||||
'token_type' => 'Bearer',
|
||||
]);
|
||||
'message' => 'Registrasi berhasil. Akun Anda berstatus pending dan sedang menunggu verifikasi Super Admin.'
|
||||
], 201);
|
||||
}
|
||||
|
||||
public function me(Request $request): JSONResponse
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
namespace App\Http\Controllers\Api\Master;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
namespace App\Http\Controllers\Api\Master;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\Master;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
use App\Http\Resources\Pertanian\JenisKomoditasResource;
|
||||
use App\Models\Pertanian\JenisKomoditas;
|
||||
|
||||
class JenisKomoditasController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index(Request $request): AnonymousResourceCollection
|
||||
{
|
||||
if (!Gate::any(['petani', 'fasilitator', 'super_admin'])) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$size = $request->integer('size') ?: 10;
|
||||
|
||||
$jenisKomoditasList = JenisKomoditas::when($request->search, function ($q, $search) {
|
||||
$search = strtolower($search);
|
||||
$q->whereRaw('lower(nama) like ?', ["%{$search}%"]);
|
||||
})
|
||||
->when($request->kode, fn($q, $v) => $q->where('kode', $v));
|
||||
|
||||
if ($request->filled('sort')) {
|
||||
$dir = str_starts_with($request->sort, '-') ? 'desc' : 'asc';
|
||||
$column = ltrim($request->sort, '-');
|
||||
|
||||
$allowed = ['id', 'nama', 'kode'];
|
||||
|
||||
if (in_array($column, $allowed)) {
|
||||
$jenisKomoditasList->orderBy($column, $dir);
|
||||
}
|
||||
} else {
|
||||
$jenisKomoditasList->orderBy('nama', 'asc');
|
||||
}
|
||||
|
||||
$jenisKomoditasList = $jenisKomoditasList->paginate($size);
|
||||
|
||||
return JenisKomoditasResource::collection($jenisKomoditasList);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
if (!Gate::any(['petani', 'fasilitator', 'super_admin'])) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$validated = $request->validate([
|
||||
'nama' => ['required', 'string', 'max:255'],
|
||||
'kode' => ['required', 'string', 'max:50', 'unique:jenis_komoditas,kode'],
|
||||
'keterangan' => ['nullable', 'string'],
|
||||
]);
|
||||
|
||||
$jenisKomoditas = JenisKomoditas::create($validated);
|
||||
|
||||
return (new JenisKomoditasResource($jenisKomoditas))
|
||||
->response()
|
||||
->setStatusCode(201);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(string $id): JsonResponse
|
||||
{
|
||||
if (!Gate::any(['petani', 'fasilitator', 'super_admin'])) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$jenisKomoditas = JenisKomoditas::findOrFail($id);
|
||||
|
||||
return (new JenisKomoditasResource($jenisKomoditas))->response();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, string $id): JsonResponse
|
||||
{
|
||||
if (!Gate::any(['petani', 'fasilitator', 'super_admin'])) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$jenisKomoditas = JenisKomoditas::findOrFail($id);
|
||||
|
||||
$validated = $request->validate([
|
||||
'nama' => ['required', 'string', 'max:255'],
|
||||
'kode' => ['required', 'string', 'max:50', Rule::unique('jenis_komoditas', 'kode')->ignore($jenisKomoditas->id)],
|
||||
'keterangan' => ['nullable', 'string'],
|
||||
]);
|
||||
|
||||
$jenisKomoditas->update($validated);
|
||||
|
||||
return (new JenisKomoditasResource($jenisKomoditas))->response();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(string $id): JsonResponse
|
||||
{
|
||||
if (!Gate::any(['petani', 'fasilitator', 'super_admin'])) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$jenisKomoditas = JenisKomoditas::findOrFail($id);
|
||||
$jenisKomoditas->delete();
|
||||
|
||||
return response()->json(null, 204);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
namespace App\Http\Controllers\Api\Master;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
namespace App\Http\Controllers\Api\Master;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
namespace App\Http\Controllers\Api\Master;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
namespace App\Http\Controllers\Api\Master;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Models\Map\PanenTanaman;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Exception;
|
||||
|
||||
class PanenTanamanController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
try {
|
||||
$panenTanaman = PanenTanaman::latest()->get();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Daftar data panen tanaman berhasil diambil.',
|
||||
'data' => $panenTanaman
|
||||
], 200);
|
||||
} catch (Exception $e) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Terjadi kesalahan saat mengambil data.',
|
||||
'error' => $e->getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'panen_id' => 'required|integer',
|
||||
'tanaman_id' => 'required|integer',
|
||||
'commodity_name' => 'required|string|max:255',
|
||||
'sync_status' => 'nullable|string|max:50',
|
||||
'weight_kg' => 'required|numeric|min:0',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Validasi gagal.',
|
||||
'errors' => $validator->errors()
|
||||
], 422);
|
||||
}
|
||||
|
||||
try {
|
||||
$panenTanaman = PanenTanaman::create($request->all());
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Data panen tanaman berhasil disimpan.',
|
||||
'data' => $panenTanaman
|
||||
], 201);
|
||||
} catch (Exception $e) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Gagal menyimpan data.',
|
||||
'error' => $e->getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(PanenTanaman $panenTanaman)
|
||||
{
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Detail data panen tanaman ditemukan.',
|
||||
'data' => $panenTanaman
|
||||
], 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, PanenTanaman $panenTanaman)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'panen_id' => 'sometimes|required|integer',
|
||||
'tanaman_id' => 'sometimes|required|integer',
|
||||
'commodity_name' => 'sometimes|required|string|max:255',
|
||||
'sync_status' => 'nullable|string|max:50',
|
||||
'weight_kg' => 'sometimes|required|numeric|min:0',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Validasi gagal.',
|
||||
'errors' => $validator->errors()
|
||||
], 422);
|
||||
}
|
||||
|
||||
try {
|
||||
$panenTanaman->update($request->all());
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Data panen tanaman berhasil diperbarui.',
|
||||
'data' => $panenTanaman
|
||||
], 200);
|
||||
} catch (Exception $e) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Gagal memperbarui data.',
|
||||
'error' => $e->getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(PanenTanaman $panenTanaman)
|
||||
{
|
||||
try {
|
||||
$panenTanaman->delete(); // Karena pakai SoftDeletes, data tidak terhapus permanen di DB
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Data panen tanaman berhasil dihapus (soft delete).'
|
||||
], 200);
|
||||
} catch (Exception $e) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Gagal menghapus data.',
|
||||
'error' => $e->getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
namespace App\Http\Controllers\Api\Produktivitas;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
namespace App\Http\Controllers\Api\Produktivitas;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Map\InsLahan;
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers\Api;
|
||||
namespace App\Http\Controllers\Api\Produktivitas;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Map\Inspeksi;
|
||||
+40
-6
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
namespace App\Http\Controllers\Api\Produktivitas;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -87,6 +87,9 @@ class LahanController extends Controller
|
||||
if (!$profile) {
|
||||
abort(404, 'Profile tidak ditemukan');
|
||||
}
|
||||
if ($request->has('profile_id')) {
|
||||
$request->merge(['profile_id' => (int) $request->profile_id]);
|
||||
}
|
||||
|
||||
$profileRule = $user->role === 'fasilitator' ? ['required', 'numeric', 'exists:profiles,id'] : ['nullable'];
|
||||
|
||||
@@ -94,10 +97,12 @@ class LahanController extends Controller
|
||||
'nama' => ['required', 'string', 'max:255'],
|
||||
'status_kepemilikan' => ['required', new Enum(StatusLahan::class)],
|
||||
'desa_kelurahan_id' => ['nullable', 'numeric', 'exists:master_desa_kelurahan,id'],
|
||||
'path' => ['nullable', 'array'],
|
||||
'path.*' => ['array'],
|
||||
'path' => ['nullable', 'string'],
|
||||
'luas_lahan' => ['nullable', 'numeric'],
|
||||
'uid' => ['required', 'string'],
|
||||
'profile_id' => $profileRule,
|
||||
'foto' => ['nullable', 'array'],
|
||||
'foto.*' => ['image', 'mimes:jpeg,png,jpg', 'max:5120'], // Max 5MB
|
||||
]);
|
||||
|
||||
$targetProfileId = $user->role === 'fasilitator'
|
||||
@@ -116,10 +121,22 @@ class LahanController extends Controller
|
||||
? $profile->desa_kelurahan_id
|
||||
: ($validated['desa_kelurahan_id'] ?? $profile->desa_kelurahan_id);
|
||||
|
||||
$fotoPaths = [];
|
||||
if ($request->hasFile('foto')) {
|
||||
foreach ($request->file('foto') as $file) {
|
||||
$fotoPaths[] = $file->store('foto_lahan', 'public');
|
||||
}
|
||||
}
|
||||
|
||||
$lahan = Lahan::create([
|
||||
...$validated,
|
||||
'profile_id' => $profile->id,
|
||||
'nama' => $validated['nama'],
|
||||
'status_kepemilikan' => $validated['status_kepemilikan'],
|
||||
'desa_kelurahan_id' => $desaKelurahanId,
|
||||
'path' => $validated['path'] ?? null,
|
||||
'luas_lahan' => $validated['luas_lahan'] ?? null,
|
||||
'uid' => $validated['uid'],
|
||||
'profile_id' => $profile->id,
|
||||
'foto' => $fotoPaths,
|
||||
]);
|
||||
|
||||
return (new LahanResource($lahan))
|
||||
@@ -169,9 +186,26 @@ class LahanController extends Controller
|
||||
'path' => ['nullable', 'array'],
|
||||
'path.*' => ['array'],
|
||||
'luas_lahan' => ['nullable', 'numeric'],
|
||||
'foto' => ['nullable', 'array'],
|
||||
'foto.*' => ['image', 'mimes:jpeg,png,jpg', 'max:5120'],
|
||||
]);
|
||||
|
||||
$lahan->update($validated);
|
||||
$fotoPaths = $lahan->foto ?? [];
|
||||
|
||||
if ($request->hasFile('foto')) {
|
||||
foreach ($request->file('foto') as $file) {
|
||||
$fotoPaths[] = $file->store('foto_lahan', 'public');
|
||||
}
|
||||
}
|
||||
|
||||
$lahan->update([
|
||||
'nama' => $validated['nama'],
|
||||
'status_kepemilikan' => $validated['status_kepemilikan'],
|
||||
'desa_kelurahan_id' => $validated['desa_kelurahan_id'] ?? $lahan->desa_kelurahan_id,
|
||||
'path' => $validated['path'] ?? null,
|
||||
'luas_lahan' => $validated['luas_lahan'] ?? null,
|
||||
'foto' => $fotoPaths,
|
||||
]);
|
||||
|
||||
return (new LahanResource($lahan))->response();
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
namespace App\Http\Controllers\Api\Produktivitas;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -0,0 +1,165 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\Produktivitas;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
use App\Models\Map\Panen;
|
||||
|
||||
class PanenController extends Controller
|
||||
{
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
if (!Gate::any(['petani', 'fasilitator','super_admin'])) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$user = Auth::user();
|
||||
$profile = $user->profile;
|
||||
|
||||
$profileId = $user->role === 'petani' ? $profile->id : $request->id;
|
||||
$listPanen = Panen::when($profileId, fn($q,$v) => $q->where('farmer_id',$user->id))->get();
|
||||
|
||||
return response()->json($listPanen);
|
||||
}
|
||||
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
if (!Gate::any(['petani', 'fasilitator', 'super_admin'])) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$validated = $request->validate([
|
||||
'uid' => ['required', 'string'],
|
||||
'title' => ['required', 'string'],
|
||||
'land_id' => ['required', 'integer'],
|
||||
'farmer_id' => ['required', 'integer'],
|
||||
'land_description' => ['nullable', 'string'],
|
||||
'harvest_date' => ['required', 'date'],
|
||||
'commodities' => ['required', 'array', 'min:1'],
|
||||
'commodities.*.tanaman_id' => ['nullable', 'integer'],
|
||||
'commodities.*.commodity_name' => ['required', 'string'],
|
||||
'commodities.*.weight_kg' => ['required', 'numeric'],
|
||||
'notes' => ['nullable', 'string'],
|
||||
]);
|
||||
|
||||
try {
|
||||
$panen = DB::transaction(function () use ($validated) {
|
||||
|
||||
$panenData = collect($validated)->except('commodities')->toArray();
|
||||
$panen = Panen::create($panenData);
|
||||
|
||||
foreach ($validated['commodities'] as $commodity) {
|
||||
\App\Models\Map\PanenTanaman::create([
|
||||
'panen_id' => $panen->id,
|
||||
'tanaman_id' => $commodity['tanaman_id'] ?? null,
|
||||
'commodity_name' => $commodity['commodity_name'],
|
||||
'weight_kg' => $commodity['weight_kg'],
|
||||
'sync_status' => 'synced',
|
||||
]);
|
||||
}
|
||||
|
||||
return $panen;
|
||||
});
|
||||
$panen->load('panenTanaman');
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Data panen dan detail tanaman berhasil disimpan.',
|
||||
'data' => $panen
|
||||
], 201);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Gagal menyimpan data ke database.',
|
||||
'error' => $e->getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function show(string $id): JsonResponse
|
||||
{
|
||||
if (!Gate::any(['petani', 'fasilitator','super_admin'])) {
|
||||
abort(403);
|
||||
}
|
||||
$panen = Panen::findOrFail($id);
|
||||
return response()->json($panen);
|
||||
}
|
||||
|
||||
public function update(Request $request, string $id): JsonResponse
|
||||
{
|
||||
if (!Gate::any(['petani', 'fasilitator','super_admin'])) {
|
||||
abort(403);
|
||||
}
|
||||
$panen = Panen::findOrFail($id);
|
||||
|
||||
$validated = $request->validate([
|
||||
'commodity_name' => ['string', 'max:255'],
|
||||
'weight_kg' => ['numeric'],
|
||||
'harvest_date' => ['date'],
|
||||
'notes' => ['nullable', 'string'],
|
||||
]);
|
||||
|
||||
$panen->update($validated);
|
||||
return response()->json($panen);
|
||||
}
|
||||
|
||||
public function destroy(string $id): JsonResponse
|
||||
{
|
||||
Gate::authorize(['petani', 'fasilitator']);
|
||||
Panen::findOrFail($id)->delete();
|
||||
return response()->json(null, 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Digunakan untuk sinkronisasi massal dari data lokal (offline)
|
||||
*/
|
||||
public function batchUpsert(Request $request): JsonResponse
|
||||
{
|
||||
if (Gate::authorize(['petani', 'fasilitator','super_admin'])) {
|
||||
abort(403);
|
||||
}
|
||||
$profileId = Auth::user()->profile->id;
|
||||
|
||||
$validated = $request->validate([
|
||||
'panens' => ['required', 'array'],
|
||||
'panens.*.id' => ['nullable', 'integer'],
|
||||
'panens.*.land_id' => ['required', 'integer'],
|
||||
'panens.*.plant_id' => ['required', 'integer'],
|
||||
'panens.*.commodity_name' => ['required', 'string'],
|
||||
'panens.*.weight_kg' => ['required', 'numeric'],
|
||||
'panens.*.harvest_date' => ['required', 'date'],
|
||||
]);
|
||||
|
||||
$dataUpsert = [];
|
||||
foreach ($validated['panens'] as $item) {
|
||||
$dataUpsert[] = [
|
||||
'id' => $item['id'] ?? null,
|
||||
'land_id' => $item['land_id'],
|
||||
'plant_id' => $item['plant_id'],
|
||||
'farmer_id' => $profileId,
|
||||
'commodity_name' => $item['commodity_name'],
|
||||
'weight_kg' => $item['weight_kg'],
|
||||
'harvest_date' => $item['harvest_date'],
|
||||
'sync_status' => 'synced',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
];
|
||||
}
|
||||
|
||||
// Melakukan upsert berdasarkan ID
|
||||
Panen::upsert($dataUpsert, ['id'], [
|
||||
'weight_kg', 'commodity_name', 'harvest_date', 'sync_status', 'updated_at'
|
||||
]);
|
||||
|
||||
return response()->json(['status' => 'success'], 200);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
namespace App\Http\Controllers\Api\Produktivitas;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -10,7 +10,7 @@ use Illuminate\Support\Facades\Gate;
|
||||
|
||||
use App\Models\Map\Panen;
|
||||
|
||||
class PanenController extends Controller
|
||||
class PanenController01 extends Controller
|
||||
{
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
namespace App\Http\Controllers\Api\Produktivitas;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -0,0 +1,210 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\Produktivitas;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
||||
use Illuminate\Validation\Rules\Enum;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
use App\Http\Resources\Pertanian\TanamanResource;
|
||||
use App\Models\Pertanian\Tanaman;
|
||||
use App\Enums\KondisiTanaman;
|
||||
|
||||
class TanamanController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index(Request $request): AnonymousResourceCollection
|
||||
{
|
||||
if (!Gate::any(['petani', 'fasilitator','super_admin'])) {
|
||||
abort(403);
|
||||
}
|
||||
$user = Auth::user();
|
||||
$profile = $user->profile;
|
||||
$profileId = $user->role === 'petani' ? $profile->id : $request->profile_id;
|
||||
|
||||
$size = $request->integer('size') ?: 10;
|
||||
|
||||
$tanamanList = Tanaman::when($request->search, function ($q, $search) {
|
||||
$search = strtolower($search);
|
||||
$q->whereRaw('lower(nama) like ?', ["%{$search}%"]);
|
||||
})
|
||||
->when($profileId, fn($q,$v) => $q->where('profile_id',$v))
|
||||
->when($request->status_kepemilikan, fn($q,$v) => $q->where('status_kepemilikan',$v))
|
||||
->when($request->lahan_id, fn($q,$v) => $q->where('lahan_id',$v))
|
||||
->when($request->komoditas_id, fn($q,$v) => $q->where('komoditas_id',$v))
|
||||
->when($request->desa_kelurahan_id, fn($q,$v) =>
|
||||
$q->whereHas('lahan', fn($k)
|
||||
=> $k->where('desa_kelurahan_id',$v)
|
||||
)
|
||||
)
|
||||
->when($request->kecamatan_id, fn ($q, $v) =>
|
||||
$q->whereHas('lahan.desaKelurahan', fn ($k) =>
|
||||
$k->where('kecamatan_id', $v)
|
||||
)
|
||||
)
|
||||
->when($request->kabupaten_kota_id, fn ($q, $v) =>
|
||||
$q->whereHas('lahan.desaKelurahan.kecamatan', fn ($k) =>
|
||||
$k->where('kabupaten_kota_id', $v)
|
||||
)
|
||||
)
|
||||
->when($request->provinsi_id, fn ($q, $v) =>
|
||||
$q->whereHas('lahan.desaKelurahan.kecamatan.kabupatenkota', fn ($k) =>
|
||||
$k->where('provinsi_id', $v)
|
||||
)
|
||||
);
|
||||
|
||||
if ($request->filled('sort')) {
|
||||
$dir = str_starts_with($request->sort, '-') ? 'desc' : 'asc';
|
||||
$column = ltrim($request->sort, '-');
|
||||
|
||||
$allowed = ['id', 'nama'];
|
||||
|
||||
if (in_array($column, $allowed)) {
|
||||
$tanamanList->orderBy($column, $dir);
|
||||
}
|
||||
} else {
|
||||
$tanamanList->orderBy('nama', 'asc');
|
||||
}
|
||||
|
||||
$tanamanList = $tanamanList->paginate($size);
|
||||
|
||||
return TanamanResource::collection($tanamanList);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
if (!Gate::any(['petani', 'fasilitator','super_admin'])) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$user = Auth::user();
|
||||
$profile = $user->profile;
|
||||
$profileId = $user->role === 'petani' ? $profile->id : $request->profile_id;
|
||||
|
||||
$request->merge([
|
||||
'komoditas_id' => $request->input('komoditas.id') ?? $request->input('komoditas_id'),
|
||||
'lahan_id' => $request->input('lahan.id') ?? $request->input('lahan_id'),
|
||||
'profile_id' => $profileId,
|
||||
]);
|
||||
|
||||
$validated = $request->validate([
|
||||
'nama' => ['required', 'string', 'max:255'],
|
||||
'komoditas_id' => ['required', 'exists:master_komoditas,id'],
|
||||
'lahan_id' => [
|
||||
'required',
|
||||
Rule::exists('map_lahan', 'id')->where(function ($query) use ($profileId) {
|
||||
$query->where('profile_id', $profileId)
|
||||
->whereNull('deleted_at');
|
||||
}),
|
||||
],
|
||||
'latitude' => ['nullable', 'numeric', 'between:-90,90', 'required_with:longitude'],
|
||||
'longitude' => ['nullable', 'numeric', 'between:-180,180', 'required_with:latitude'],
|
||||
'kondisi_tanaman' => ['nullable', 'string', new Enum(KondisiTanaman::class)],
|
||||
]);
|
||||
|
||||
$tanaman = Tanaman::create([
|
||||
...$validated,
|
||||
'profile_id' => $profile->id,
|
||||
]);
|
||||
|
||||
return (new TanamanResource($tanaman))
|
||||
->response()
|
||||
->setStatusCode(201);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(string $id): JsonResponse
|
||||
{
|
||||
if (!Gate::any(['petani', 'fasilitator','super_admin'])) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$tanaman = Tanaman::findOrFail($id);
|
||||
if ($tanaman->profile_id !== Auth::user()->profile->id) {
|
||||
return response()->json(['message' => 'Unauthorized'], 403);
|
||||
}
|
||||
|
||||
return (new TanamanResource($tanaman))->response();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, string $id): JsonResponse
|
||||
{
|
||||
if (!Gate::any(['petani', 'fasilitator','super_admin'])) {
|
||||
abort(403);
|
||||
}
|
||||
$tanaman = Tanaman::findOrFail($id);
|
||||
if ($tanaman->profile_id !== Auth::user()->profile->id) {
|
||||
return response()->json(['message' => 'Unauthorized'], 403);
|
||||
}
|
||||
|
||||
$profile = Auth::user()->profile;
|
||||
|
||||
$validated = $request->validate([
|
||||
'nama' => ['required', 'string', 'max:255'],
|
||||
'komoditas_id' => ['required', 'exists:master_komoditas,id'],
|
||||
'lahan_id' => [
|
||||
'required',
|
||||
Rule::exists('map_lahan', 'id')->where(function ($query) use ($profile) {
|
||||
$query->where('profile_id', $profile->id)
|
||||
->whereNull('deleted_at');
|
||||
}),
|
||||
],
|
||||
'latitude' => ['nullable', 'numeric', 'between:-90,90', 'required_with:longitude'],
|
||||
'longitude' => ['nullable', 'numeric', 'between:-180,180', 'required_with:latitude'],
|
||||
'kondisi_tanaman' => ['nullable', 'string', new Enum(KondisiTanaman::class)],
|
||||
]);
|
||||
|
||||
$tanaman->update($validated);
|
||||
|
||||
return (new TanamanResource($tanaman))->response();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(string $id): JsonResponse
|
||||
{
|
||||
if (!Gate::any(['petani', 'fasilitator','super_admin'])) {
|
||||
abort(403);
|
||||
}
|
||||
$tanaman = Tanaman::findOrFail($id);
|
||||
if ($tanaman->profile_id !== Auth::user()->profile->id) {
|
||||
return response()->json(['message' => 'Unauthorized'], 403);
|
||||
}
|
||||
|
||||
$tanaman->delete();
|
||||
|
||||
return response()->json(null, 204);
|
||||
}
|
||||
}
|
||||
@@ -94,26 +94,41 @@ class TanamanController extends Controller
|
||||
if (!Gate::any(['petani', 'fasilitator','super_admin'])) {
|
||||
abort(403);
|
||||
}
|
||||
$profile = Auth::user()->profile;
|
||||
|
||||
$user = Auth::user();
|
||||
$profileId = $user->role === 'petani' ? $user->profile->id : $request->profile_id;
|
||||
$lahanId = $request->input('lahan_id') ?? $request->input('land_id') ?? $request->input('lahan.id');
|
||||
|
||||
$request->merge([
|
||||
'komoditas_id' => $request->input('komoditas.id') ?? $request->input('komoditas_id'),
|
||||
'lahan_id' => $lahanId,
|
||||
'profile_id' => $profileId,
|
||||
'uid' => $request->input('uid'),
|
||||
'created_by' => $user->id,
|
||||
]);
|
||||
$validated = $request->validate([
|
||||
'nama' => ['required', 'string', 'max:255'],
|
||||
'komoditas_id' => ['required', 'exists:master_komoditas,id'],
|
||||
'lahan_id' => [
|
||||
'required',
|
||||
Rule::exists('map_lahan', 'id')->where(function ($query) use ($profile) {
|
||||
$query->where('profile_id', $profile->id)
|
||||
->whereNull('deleted_at');
|
||||
}),
|
||||
],
|
||||
'lahan_id' => ['required', 'exists:map_lahan,id'],
|
||||
'profile_id' => ['required', 'exists:profiles,id'],
|
||||
'latitude' => ['nullable', 'numeric', 'between:-90,90', 'required_with:longitude'],
|
||||
'longitude' => ['nullable', 'numeric', 'between:-180,180', 'required_with:latitude'],
|
||||
'kondisi_tanaman' => ['nullable', 'string', new Enum(KondisiTanaman::class)],
|
||||
'uid' => ['required', 'string'],
|
||||
'jenis_komoditas_id' => ['nullable', 'exists:jenis_komoditas,id'],
|
||||
'komoditas_kode' => ['nullable', 'string', 'max:255'],
|
||||
'varietas_id' => ['nullable', 'numeric'],
|
||||
'metode_pengumpulan' => ['nullable', 'string'],
|
||||
'deskripsi' => ['nullable', 'string'],
|
||||
'created_by' => ['nullable', 'numeric'],
|
||||
]);
|
||||
|
||||
$tanaman = Tanaman::create([
|
||||
...$validated,
|
||||
'profile_id' => $profile->id,
|
||||
// 'profile_id' => $profileId,
|
||||
// 'uid' => $validated['uid'],
|
||||
// 'komoditas_kode' => $validated['komoditas_kode'] ?? null,
|
||||
// 'jenis_komoditas_id' => $validated['jenis_komoditas_id'] ?? null,
|
||||
]);
|
||||
|
||||
return (new TanamanResource($tanaman))
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Web\Dashboard;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
class DistribusiController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
if (!Gate::allows('super_admin') && !Gate::allows('admin')) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$title = 'Distribusi Dashboard';
|
||||
|
||||
return view('dashboard.distribusi', compact('title'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Web\Dashboard;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
use App\Models\Pertanian\Petani;
|
||||
use App\Models\Pertanian\Komoditas;
|
||||
use App\Models\Pertanian\Lahan;
|
||||
use App\Models\Pertanian\Tanaman;
|
||||
use App\Models\Pertanian\SkorPetani;
|
||||
|
||||
class ProfilPetaniController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
if (!Gate::any(['super_admin', 'admin', 'fasilitator'])) {
|
||||
abort(403);
|
||||
}
|
||||
$title = 'Dashboard Profil Petani';
|
||||
|
||||
$komoditas = Komoditas::where('is_utama', true)->get();
|
||||
|
||||
$petani = Petani::pluck('id');
|
||||
$lahan = Lahan::whereIn('petani_id', $petani)->get();
|
||||
|
||||
$petaniSummary = Petani::select(
|
||||
'komoditas_id',
|
||||
DB::raw('COUNT(*) as total')
|
||||
)
|
||||
->groupBy('komoditas_id')
|
||||
->get();
|
||||
$lahanSummary = Lahan::select(
|
||||
'komoditas_id',
|
||||
DB::raw('COUNT(*) as total'),
|
||||
DB::raw('SUM(luas_lahan) as luas_lahan')
|
||||
)
|
||||
->whereIn('petani_id', $petani)
|
||||
->groupBy('komoditas_id')
|
||||
->get();
|
||||
$tanamanSummary = Tanaman::select(
|
||||
'komoditas_id',
|
||||
DB::raw('COUNT(*) as total')
|
||||
)
|
||||
->whereIn('lahan_id', $lahan->pluck('id'))
|
||||
->groupBy('komoditas_id')
|
||||
->get();
|
||||
|
||||
$case = "
|
||||
CASE
|
||||
WHEN skor_kesiapan_adopsi >= 4.0 THEN 'Penggerak'
|
||||
WHEN skor_kesiapan_adopsi >= 3.0 THEN 'Perintis'
|
||||
WHEN skor_kesiapan_adopsi >= 2.0 THEN 'Pemerhati'
|
||||
WHEN skor_kesiapan_adopsi >= 1.0 THEN 'Pemula'
|
||||
ELSE 'Belum Lengkap'
|
||||
END
|
||||
";
|
||||
$skorSummary = SkorPetani::selectRaw("$case AS segmen, COUNT(*) AS total")
|
||||
->whereIn('petani_id', $petani)
|
||||
->groupByRaw($case)
|
||||
->get();
|
||||
|
||||
$skorKomoditasSummary = SkorPetani::query()
|
||||
->join('petani', 'petani_skor.petani_id', '=', 'petani.id')
|
||||
->selectRaw("
|
||||
petani.komoditas_id,
|
||||
$case AS segmen,
|
||||
COUNT(petani.id) AS total
|
||||
")
|
||||
->whereIn('petani_skor.petani_id', $petani)
|
||||
->groupBy('petani.komoditas_id')
|
||||
->groupByRaw($case)
|
||||
->get();
|
||||
|
||||
|
||||
$skorAverage = SkorPetani::query()
|
||||
->join('petani', 'petani_skor.petani_id', '=', 'petani.id')
|
||||
->whereIn('petani_id', $petani)
|
||||
->whereIn('petani.komoditas_id', $komoditas->pluck('id'))
|
||||
->avg('skor_kesiapan_adopsi');
|
||||
if ($skorAverage >= 4.0) {
|
||||
$segmenAverage = 'Penggerak';
|
||||
} elseif ($skorAverage >= 3.0) {
|
||||
$segmenAverage = 'Perintis';
|
||||
} elseif ($skorAverage >= 2.0) {
|
||||
$segmenAverage = 'Pemerhati';
|
||||
} elseif ($skorAverage >= 1.0) {
|
||||
$segmenAverage = 'Pemula';
|
||||
} else {
|
||||
$segmenAverage = 'Belum Lengkap';
|
||||
}
|
||||
|
||||
$skorDimensi = SkorPetani::query()
|
||||
->join('petani', 'petani_skor.petani_id', '=', 'petani.id')
|
||||
->whereIn('petani_id', $petani)
|
||||
->whereIn('petani.komoditas_id', $komoditas->pluck('id'))
|
||||
->selectRaw("
|
||||
avg(skor_d2_sistem_praktik_budidaya) as skor_d2_sistem_praktik_budidaya,
|
||||
avg(skor_d4_sosial_ekonomi) as skor_d4_sosial_ekonomi,
|
||||
avg(skor_d6_rantai_nilai_akses_pasar) as skor_d6_rantai_nilai_akses_pasar")
|
||||
->first();
|
||||
|
||||
$skorKomponen = SkorPetani::query()
|
||||
->join('petani', 'petani_skor.petani_id', '=', 'petani.id')
|
||||
->whereIn('petani_id', $petani)
|
||||
->whereIn('petani.komoditas_id', $komoditas->pluck('id'))
|
||||
->selectRaw("avg(skor_komp_1_d4_k3_motivasi_kapasitas_adopsi) as skor_komp_1_d4_k3_motivasi_kapasitas_adopsi,
|
||||
avg(skor_komp_2_d4_k2_ekonomi_rumah_tangga) as skor_komp_2_d4_k2_ekonomi_rumah_tangga,
|
||||
avg(skor_komp_3_d2_praktik_budidaya_gap) as skor_komp_3_d2_praktik_budidaya_gap,
|
||||
avg(skor_komp_4_d4_k4_keterlibatan_kelembagaan) as skor_komp_4_d4_k4_keterlibatan_kelembagaan,
|
||||
avg(skor_komp_5_d4_k5_k6_akses_kebebasan_keuangan) as skor_komp_5_d4_k5_k6_akses_kebebasan_keuanga,
|
||||
avg(skor_komp_6_d6_k1_k4_k5_rantai_nilai_akses_pasar) as skor_komp_6_d6_k1_k4_k5_rantai_nilai_akses_pasar")
|
||||
->first();
|
||||
|
||||
$skorMultiDimensi = SkorPetani::query()
|
||||
->join('petani', 'petani_skor.petani_id', '=', 'petani.id')
|
||||
->whereIn('petani_id', $petani)
|
||||
->whereIn('petani.komoditas_id', $komoditas->pluck('id'))
|
||||
->selectRaw("$case AS segmen,
|
||||
avg(skor_kesiapan_adopsi) as skor_kesiapan_adopsi,
|
||||
avg(skor_d2_sistem_praktik_budidaya) as skor_d2_sistem_praktik_budidaya,
|
||||
avg(skor_d4_sosial_ekonomi) as skor_d4_sosial_ekonomi,
|
||||
avg(skor_d6_rantai_nilai_akses_pasar) as skor_d6_rantai_nilai_akses_pasar")
|
||||
->groupByRaw($case)
|
||||
->get();
|
||||
|
||||
$petani = Petani::with(['skor'])
|
||||
->whereIn('id', $petani)
|
||||
->whereIn('komoditas_id', $komoditas->pluck('id'))
|
||||
->get();
|
||||
|
||||
return view('dashboard.petani', compact('title',
|
||||
'komoditas',
|
||||
'petaniSummary',
|
||||
'lahanSummary',
|
||||
'tanamanSummary',
|
||||
'skorSummary',
|
||||
'skorKomoditasSummary',
|
||||
'segmenAverage',
|
||||
'skorAverage',
|
||||
'skorDimensi',
|
||||
'skorKomponen',
|
||||
'skorMultiDimensi',
|
||||
'petani',
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ use App\Models\Wilayah\Kecamatan;
|
||||
use App\Models\Wilayah\DesaKelurahan;
|
||||
use App\Models\Pertanian\Lahan;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
class SummaryController extends Controller
|
||||
{
|
||||
public function index()
|
||||
@@ -22,39 +23,9 @@ class SummaryController extends Controller
|
||||
return view('dashboard.summary', compact('title'));
|
||||
}
|
||||
|
||||
public function produktivitasBackup(Request $request)
|
||||
{
|
||||
if (!Gate::allows('super_admin') && !Gate::allows('admin')) {
|
||||
abort(403);
|
||||
}
|
||||
$title = 'Produktivitas Dashboard';
|
||||
$luasTotal = Lahan::whereNotNull('path')->sum('luas_lahan');
|
||||
$totalpetani = Profile::where('role', 'petani')->count();
|
||||
$totallahan = Lahan::whereNotNull('path')->count();
|
||||
|
||||
$petaniList = Profile::where('role', 'petani')
|
||||
->with(['lahan.tanaman.komoditas', 'desaKelurahan'])
|
||||
->paginate(20);
|
||||
|
||||
$allLahan = Lahan::whereNotNull('path')
|
||||
->with(['profile', 'tanaman.komoditas', 'desaKelurahan.kecamatan.kabupatenKota.provinsi'])
|
||||
->get()
|
||||
->map(function($lahan) {
|
||||
return [
|
||||
'id' => $lahan->id,
|
||||
'polygon' => $lahan->path,
|
||||
'nama_petani' => $lahan->profile->nama ?? 'N/A',
|
||||
'luas' => $lahan->luas_lahan,
|
||||
'tanaman' => $lahan->tanaman->map(fn($t) => $t->komoditas->nama ?? null)->filter()->unique()->values()
|
||||
];
|
||||
});
|
||||
|
||||
return view('dashboard.produktivitas', compact('title', 'petaniList', 'allLahan', 'totalpetani', 'totallahan', 'luasTotal'));
|
||||
}
|
||||
|
||||
public function produktivitas(Request $request)
|
||||
{
|
||||
if (!Gate::allows('super_admin') && !Gate::allows('admin')) {
|
||||
if (!Gate::allows('super_admin') && !Gate::allows('admin') && !Gate::allows('fasilitator')) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
@@ -71,7 +42,6 @@ class SummaryController extends Controller
|
||||
->with(['profile', 'tanaman.komoditas', 'desaKelurahan.kecamatan.kabupatenKota.provinsi'])
|
||||
->get();
|
||||
|
||||
// Penampung data per level (menggunakan ID sebagai key agar unique)
|
||||
$geoProvinsi = [];
|
||||
$geoKabupaten = [];
|
||||
$geoKecamatan = [];
|
||||
@@ -84,7 +54,6 @@ class SummaryController extends Controller
|
||||
$kab = $kec ? $kec->kabupatenKota : null;
|
||||
$prov = $kab ? $kab->provinsi : null;
|
||||
|
||||
// --- Akumulasi Provinsi ---
|
||||
if ($prov && $prov->path) {
|
||||
if (!isset($geoProvinsi[$prov->id])) {
|
||||
$geoProvinsi[$prov->id] = ['id' => $prov->id, 'nama' => $prov->nama, 'polygon' => $prov->path, 'total_lahan' => 0, 'total_luas' => 0];
|
||||
@@ -93,7 +62,6 @@ class SummaryController extends Controller
|
||||
$geoProvinsi[$prov->id]['total_luas'] += $lahan->luas_lahan;
|
||||
}
|
||||
|
||||
// --- Akumulasi Kabupaten ---
|
||||
if ($kab && $kab->path) {
|
||||
if (!isset($geoKabupaten[$kab->id])) {
|
||||
$geoKabupaten[$kab->id] = ['id' => $kab->id, 'parent_id' => $prov->id ?? null, 'nama' => $kab->nama, 'polygon' => $kab->path, 'total_lahan' => 0, 'total_luas' => 0];
|
||||
@@ -102,7 +70,6 @@ class SummaryController extends Controller
|
||||
$geoKabupaten[$kab->id]['total_luas'] += $lahan->luas_lahan;
|
||||
}
|
||||
|
||||
// --- Akumulasi Kecamatan ---
|
||||
if ($kec && $kec->path) {
|
||||
if (!isset($geoKecamatan[$kec->id])) {
|
||||
$geoKecamatan[$kec->id] = ['id' => $kec->id, 'parent_id' => $kab->id ?? null, 'nama' => $kec->nama, 'polygon' => $kec->path, 'total_lahan' => 0, 'total_luas' => 0];
|
||||
@@ -111,7 +78,6 @@ class SummaryController extends Controller
|
||||
$geoKecamatan[$kec->id]['total_luas'] += $lahan->luas_lahan;
|
||||
}
|
||||
|
||||
// --- Akumulasi Desa ---
|
||||
if ($desa && $desa->path) {
|
||||
if (!isset($geoDesa[$desa->id])) {
|
||||
$geoDesa[$desa->id] = ['id' => $desa->id, 'parent_id' => $kec->id ?? null, 'nama' => $desa->nama, 'polygon' => $desa->path, 'total_lahan' => 0, 'total_luas' => 0];
|
||||
@@ -120,7 +86,6 @@ class SummaryController extends Controller
|
||||
$geoDesa[$desa->id]['total_luas'] += $lahan->luas_lahan;
|
||||
}
|
||||
|
||||
// Data Lahan Tetap
|
||||
$geoLahan[] = [
|
||||
'id' => $lahan->id,
|
||||
'parent_id' => $desa->id ?? null,
|
||||
@@ -137,7 +102,6 @@ class SummaryController extends Controller
|
||||
'totalpetani' => $totalpetani,
|
||||
'totallahan' => $totallahan,
|
||||
'luasTotal' => $luasTotal,
|
||||
// Reset key array agar menjadi format list normal untuk JSON
|
||||
'geoProvinsi' => array_values($geoProvinsi),
|
||||
'geoKabupaten' => array_values($geoKabupaten),
|
||||
'geoKecamatan' => array_values($geoKecamatan),
|
||||
|
||||
@@ -0,0 +1,377 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Web\Dashboard;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Pertanian\Petani;
|
||||
use App\Models\Pertanian\Komoditas;
|
||||
use App\Models\Pertanian\Lahan;
|
||||
use App\Models\Pertanian\Tanaman;
|
||||
use App\Models\Pertanian\SurveyPelatihan;
|
||||
use App\Models\Pertanian\SurveySertifikasi;
|
||||
|
||||
use BackedEnum;
|
||||
|
||||
class SurveyPetaniController extends Controller
|
||||
{
|
||||
private const GAP_ENUM_CLASS = 'App\\Enums\\PendidikanPelatihan\\PelatihanGap';
|
||||
public function index()
|
||||
{
|
||||
$colors = $this->colors();
|
||||
|
||||
// Progres per enumerator
|
||||
|
||||
$enumerators = User::query()
|
||||
->where('role', 'fasilitator')
|
||||
->withCount([
|
||||
'petaniDibuat as done',
|
||||
])
|
||||
->orderByDesc('done')
|
||||
->get()
|
||||
->map(function ($enumerator) use ($colors) {
|
||||
$color = $colors[array_rand($colors)];
|
||||
|
||||
return [
|
||||
'name' => $enumerator->name,
|
||||
'done' => (int) $enumerator->done,
|
||||
'color' => $color['color'],
|
||||
'bg' => $color['bg'],
|
||||
'tx' => $color['tx'],
|
||||
];
|
||||
})
|
||||
->values();
|
||||
|
||||
// Tabel dan nama model
|
||||
|
||||
$petaniTable = (new Petani())->getTable();
|
||||
$komoditasTable = (new Komoditas())->getTable();
|
||||
$lahanTable = (new Lahan())->getTable();
|
||||
|
||||
// Distribusi petani berdasarkan komoditas
|
||||
|
||||
$komoditasCollection = DB::table("{$petaniTable} as p")
|
||||
->leftJoin("{$komoditasTable} as k", 'k.id', '=', 'p.komoditas_id')
|
||||
->selectRaw("COALESCE(k.nama, 'Belum ditentukan') as nama")
|
||||
->selectRaw('COUNT(p.id) as petani_count')
|
||||
->where('k.is_utama', true)
|
||||
->groupBy('k.id', 'k.nama')
|
||||
->orderByDesc('petani_count')
|
||||
->get();
|
||||
|
||||
$totalPetani = (int) $komoditasCollection->sum('petani_count');
|
||||
$circumference = 2 * pi() * 46;
|
||||
|
||||
$komoditas = $komoditasCollection
|
||||
->map(function ($item, $index) use (
|
||||
$colors,
|
||||
$totalPetani,
|
||||
$circumference
|
||||
) {
|
||||
$color = $colors[$index % count($colors)];
|
||||
|
||||
$ratio = $totalPetani > 0
|
||||
? (int) $item->petani_count / $totalPetani
|
||||
: 0;
|
||||
|
||||
return [
|
||||
'label' => $item->nama,
|
||||
'total' => (int) $item->petani_count,
|
||||
'pct' => round($ratio * 100, 1),
|
||||
'arc' => $ratio * $circumference,
|
||||
'color' => $color['color'],
|
||||
];
|
||||
})
|
||||
->values();
|
||||
|
||||
// Progres pengisian data per petani
|
||||
|
||||
$progressPetani = Petani::query()
|
||||
->select([
|
||||
'id',
|
||||
'nama',
|
||||
])
|
||||
->withExists([
|
||||
'lahans as has_lahan',
|
||||
'praktikBudidaya as has_praktik_budidaya',
|
||||
'sosialEkonomi as has_sosial_ekonomi',
|
||||
'aksesPasar as has_akses_pasar',
|
||||
])
|
||||
->orderBy('nama')
|
||||
->get()
|
||||
->map(function ($petani) {
|
||||
$status = [
|
||||
'lahan' => [
|
||||
'label' => 'Lahan',
|
||||
'done' => (bool) $petani->has_lahan,
|
||||
],
|
||||
'praktik_budidaya' => [
|
||||
'label' => 'Praktik Budidaya',
|
||||
'done' => (bool) $petani->has_praktik_budidaya,
|
||||
],
|
||||
'sosial_ekonomi' => [
|
||||
'label' => 'Sosial Ekonomi',
|
||||
'done' => (bool) $petani->has_sosial_ekonomi,
|
||||
],
|
||||
'akses_pasar' => [
|
||||
'label' => 'Akses Pasar',
|
||||
'done' => (bool) $petani->has_akses_pasar,
|
||||
],
|
||||
];
|
||||
|
||||
$totalModul = count($status);
|
||||
|
||||
$modulSelesai = collect($status)
|
||||
->where('done', true)
|
||||
->count();
|
||||
|
||||
return [
|
||||
'id' => $petani->id,
|
||||
'name' => $petani->nama,
|
||||
'status' => $status,
|
||||
'done' => $modulSelesai,
|
||||
'total' => $totalModul,
|
||||
'percent' => $totalModul > 0
|
||||
? (int) round(($modulSelesai / $totalModul) * 100)
|
||||
: 0,
|
||||
];
|
||||
})
|
||||
->values();
|
||||
|
||||
// Ringkasan lahan
|
||||
|
||||
$totalLuasLahan = ((float) Lahan::query()
|
||||
->sum('luas_lahan')) / 10000;
|
||||
|
||||
// Jumlah tanaman berdasarkan komoditas petani
|
||||
|
||||
$tanamanTable = (new Tanaman())->getTable();
|
||||
|
||||
$tanamanPerKomoditasCollection = DB::table("{$tanamanTable} as t")
|
||||
->join("{$lahanTable} as l", 'l.id', '=', 't.lahan_id')
|
||||
->join("{$petaniTable} as p", 'p.id', '=', 'l.petani_id')
|
||||
->leftJoin("{$komoditasTable} as k", 'k.id', '=', 't.komoditas_id')
|
||||
->selectRaw("COALESCE(k.nama, 'Belum ditentukan') as label")
|
||||
->selectRaw('COUNT(t.id) as total')
|
||||
->where('k.is_utama', true)
|
||||
->whereNull('t.deleted_at')
|
||||
->whereNull('l.deleted_at')
|
||||
->whereNull('p.deleted_at')
|
||||
->groupBy('k.id', 'k.nama')
|
||||
->orderByDesc('total')
|
||||
->get();
|
||||
|
||||
$totalJumlahTanaman = (int) $tanamanPerKomoditasCollection->sum('total');
|
||||
|
||||
$tanamanPerKomoditas = $tanamanPerKomoditasCollection
|
||||
->map(function ($item, $index) use ($colors, $totalJumlahTanaman) {
|
||||
$color = $colors[$index % count($colors)];
|
||||
$total = (int) $item->total;
|
||||
|
||||
return [
|
||||
'label' => $item->label,
|
||||
'total' => $total,
|
||||
'pct' => $totalJumlahTanaman > 0
|
||||
? round(($total / $totalJumlahTanaman) * 100, 1)
|
||||
: 0,
|
||||
'color' => $color['color'],
|
||||
'bg' => $color['bg'],
|
||||
'tx' => $color['tx'],
|
||||
];
|
||||
})
|
||||
->values();
|
||||
|
||||
// Distribusi peserta pelatihan GAP
|
||||
|
||||
$gapOptions = collect($this->pelatihanGapOptions());
|
||||
|
||||
$knownGapOptions = $gapOptions->reject(function ($label, $value) {
|
||||
return $this->normalizeText((string) $value) === 'lainnya'
|
||||
|| $this->normalizeText((string) $label) === 'lainnya';
|
||||
});
|
||||
|
||||
$gapLookup = [];
|
||||
|
||||
foreach ($knownGapOptions as $value => $label) {
|
||||
$gapLookup[$this->normalizeText((string) $value)] = (string) $label;
|
||||
$gapLookup[$this->normalizeText((string) $label)] = (string) $label;
|
||||
}
|
||||
|
||||
$pelatihanPairs = SurveyPelatihan::query()
|
||||
->whereNotNull('petani_id')
|
||||
->whereNotNull('jenis_pelatihan')
|
||||
->where('jenis_pelatihan', '!=', '')
|
||||
->get([
|
||||
'petani_id',
|
||||
'jenis_pelatihan',
|
||||
])
|
||||
->map(function ($row) use ($gapLookup) {
|
||||
$normalized = $this->normalizeText((string) $row->jenis_pelatihan);
|
||||
|
||||
return [
|
||||
'petani_id' => $row->petani_id,
|
||||
'label' => $gapLookup[$normalized] ?? 'Lainnya',
|
||||
];
|
||||
})
|
||||
->unique(fn ($item) => $item['petani_id'] . '|' . $item['label'])
|
||||
->values();
|
||||
|
||||
$pelatihanCounts = $pelatihanPairs->countBy('label');
|
||||
|
||||
$pelatihanLabels = $knownGapOptions
|
||||
->values()
|
||||
->unique()
|
||||
->push('Lainnya')
|
||||
->values();
|
||||
|
||||
$pelatihanGap = $pelatihanLabels
|
||||
->map(function ($label, $index) use ($pelatihanCounts, $colors) {
|
||||
$color = $colors[$index % count($colors)];
|
||||
|
||||
return [
|
||||
'label' => $label,
|
||||
'total' => (int) $pelatihanCounts->get($label, 0),
|
||||
'color' => $color['color'],
|
||||
'bg' => $color['bg'],
|
||||
'tx' => $color['tx'],
|
||||
];
|
||||
})
|
||||
->values();
|
||||
|
||||
$totalPetaniPelatihan = $pelatihanPairs
|
||||
->pluck('petani_id')
|
||||
->unique()
|
||||
->count();
|
||||
|
||||
// Sertifikasi
|
||||
|
||||
$totalPetaniBersertifikat = SurveySertifikasi::query()
|
||||
->whereNotNull('petani_id')
|
||||
->distinct()
|
||||
->count('petani_id');
|
||||
|
||||
$totalPetaniSertifikatAktif = SurveySertifikasi::query()
|
||||
->whereNotNull('petani_id')
|
||||
->where('is_aktif', true)
|
||||
->distinct()
|
||||
->count('petani_id');
|
||||
|
||||
return view('dashboard.survey-petani', [
|
||||
'enumerators' => $enumerators,
|
||||
'komoditas' => $komoditas,
|
||||
'totalPetani' => $totalPetani,
|
||||
'circumference' => $circumference,
|
||||
'progressPetani' => $progressPetani,
|
||||
'totalLuasLahan' => $totalLuasLahan,
|
||||
'totalJumlahTanaman' => $totalJumlahTanaman,
|
||||
'tanamanPerKomoditas' => $tanamanPerKomoditas,
|
||||
'pelatihanGap' => $pelatihanGap,
|
||||
'totalPetaniPelatihan' => $totalPetaniPelatihan,
|
||||
'totalPetaniBersertifikat' => $totalPetaniBersertifikat,
|
||||
'totalPetaniSertifikatAktif' => $totalPetaniSertifikatAktif,
|
||||
]);
|
||||
}
|
||||
|
||||
private function pelatihanGapOptions(): array
|
||||
{
|
||||
$enumClass = self::GAP_ENUM_CLASS;
|
||||
|
||||
if (enum_exists($enumClass)) {
|
||||
if (method_exists($enumClass, 'options')) {
|
||||
return collect($enumClass::options())
|
||||
->mapWithKeys(function ($option, $key) {
|
||||
if (is_array($option)) {
|
||||
$value = (string) ($option['value'] ?? $key);
|
||||
$label = (string) (
|
||||
$option['label']
|
||||
?? $option['name']
|
||||
?? $option['value']
|
||||
?? $key
|
||||
);
|
||||
|
||||
return [$value => $label];
|
||||
}
|
||||
|
||||
return [(string) $key => (string) $option];
|
||||
})
|
||||
->all();
|
||||
}
|
||||
|
||||
return collect($enumClass::cases())
|
||||
->mapWithKeys(function ($case) {
|
||||
$value = $case instanceof BackedEnum
|
||||
? (string) $case->value
|
||||
: (string) $case->name;
|
||||
|
||||
$label = method_exists($case, 'label')
|
||||
? (string) $case->label()
|
||||
: Str::headline($case->name);
|
||||
|
||||
return [$value => $label];
|
||||
})
|
||||
->all();
|
||||
}
|
||||
|
||||
return [
|
||||
'pemangkasan_perawatan_tanaman'
|
||||
=> 'Pemangkasan/perawatan tanaman',
|
||||
'pemupukan_nutrisi_tanah'
|
||||
=> 'Pemupukan/nutrisi tanah',
|
||||
'pengendalian_hama_penyakit'
|
||||
=> 'Pengendalian hama & penyakit',
|
||||
'praktik_berkebun_baik_gap'
|
||||
=> 'Praktik Berkebun yang Baik (GAP)',
|
||||
'pengolahan_pascapanen'
|
||||
=> 'Pengolahan/pascapanen',
|
||||
'penyerbukan_manual_vanili'
|
||||
=> 'Penyerbukan manual (vanili)',
|
||||
'lainnya'
|
||||
=> 'Lainnya',
|
||||
];
|
||||
}
|
||||
|
||||
private function normalizeText(string $value): string
|
||||
{
|
||||
return Str::lower(Str::squish($value));
|
||||
}
|
||||
|
||||
private function colors(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'color' => '#28a745',
|
||||
'bg' => 'rgba(40,167,69,.15)',
|
||||
'tx' => '#28a745',
|
||||
],
|
||||
[
|
||||
'color' => '#007bff',
|
||||
'bg' => 'rgba(0,123,255,.15)',
|
||||
'tx' => '#007bff',
|
||||
],
|
||||
[
|
||||
'color' => '#fd7e14',
|
||||
'bg' => 'rgba(253,126,20,.15)',
|
||||
'tx' => '#fd7e14',
|
||||
],
|
||||
[
|
||||
'color' => '#dc3545',
|
||||
'bg' => 'rgba(220,53,69,.15)',
|
||||
'tx' => '#dc3545',
|
||||
],
|
||||
[
|
||||
'color' => '#6f42c1',
|
||||
'bg' => 'rgba(111,66,193,.15)',
|
||||
'tx' => '#6f42c1',
|
||||
],
|
||||
[
|
||||
'color' => '#20c997',
|
||||
'bg' => 'rgba(32,201,151,.15)',
|
||||
'tx' => '#20c997',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,296 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Web\Ekosistem;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
|
||||
use App\Models\Ekosistem\TabelBasisData;
|
||||
use App\Models\Ekosistem\FormBasisData;
|
||||
use App\Enums\LayoutForm;
|
||||
|
||||
class FormBasisDataController extends Controller
|
||||
{
|
||||
public function index(Request $request, string $tabelId): View
|
||||
{
|
||||
Gate::authorize('super_admin');
|
||||
|
||||
$tabel = TabelBasisData::find($tabelId);
|
||||
if (!$tabel) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Data tabel tidak ditemukan.'
|
||||
], 404);
|
||||
}
|
||||
|
||||
$listEnum = LayoutForm::options();
|
||||
|
||||
$tab = $request->tab ?? 'form';
|
||||
$tabel->state = 'preview';
|
||||
|
||||
return view('ekosistem.form-basis-data.index', compact('tabel', 'listEnum', 'tab'));
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function store(Request $request, string $tabelId): JsonResponse
|
||||
{
|
||||
Gate::authorize('super_admin');
|
||||
|
||||
$tabel = TabelBasisData::find($tabelId);
|
||||
if (!$tabel) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Data tabel tidak ditemukan.'
|
||||
], 404);
|
||||
}
|
||||
|
||||
$validated = $request->validate([
|
||||
'parent_id' => ['nullable', 'exists:ekosistem_basis_data_form,id'],
|
||||
'tipe' => ['required', Rule::enum(LayoutForm::class)],
|
||||
'column_width' => [
|
||||
Rule::requiredIf($request->tipe === LayoutForm::COLUMN->value),
|
||||
'nullable', 'integer', 'min:1', 'max:12'],
|
||||
'kolom_id' => [
|
||||
Rule::requiredIf($request->tipe === LayoutForm::VALUE->value),
|
||||
'nullable', 'exists:ekosistem_basis_data_kolom,id'],
|
||||
'section_label' => [
|
||||
Rule::requiredIf($request->tipe === LayoutForm::SECTION->value),
|
||||
'nullable', 'string'],
|
||||
]);
|
||||
|
||||
FormBasisData::create([...$validated,
|
||||
'tabel_id' => $tabelId,
|
||||
'created_by' => auth()->user()->id,
|
||||
'updated_by' => auth()->user()->id
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Form basis data berhasil ditambahkan.'
|
||||
], 201);
|
||||
}
|
||||
|
||||
public function show(string $tabelId, string $id): JsonResponse
|
||||
{
|
||||
Gate::authorize('super_admin');
|
||||
|
||||
$form = FormBasisData::where('tabel_id', $tabelId)->find($id);
|
||||
if (!$form) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Data formulir basis data tidak ditemukan.'
|
||||
], 404);
|
||||
}
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'data' => $form
|
||||
], 200);
|
||||
}
|
||||
|
||||
public function edit(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function update(Request $request, string $tabelId, string $id)
|
||||
{
|
||||
Gate::authorize('super_admin');
|
||||
|
||||
$form = FormBasisData::where('tabel_id', $tabelId)->find($id);
|
||||
if (!$form) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Data formulir basis data tidak ditemukan.'
|
||||
], 404);
|
||||
}
|
||||
|
||||
$validated = $request->validate([
|
||||
'parent_id' => ['nullable', 'exists:ekosistem_basis_data_form,id'],
|
||||
'tipe' => ['required', Rule::enum(LayoutForm::class)],
|
||||
'column_width' => [
|
||||
Rule::requiredIf($request->tipe === LayoutForm::COLUMN->value),
|
||||
'nullable', 'integer', 'min:1', 'max:12'],
|
||||
'kolom_id' => [
|
||||
Rule::requiredIf($request->tipe === LayoutForm::VALUE->value),
|
||||
'nullable', 'exists:ekosistem_basis_data_kolom,id'],
|
||||
'section_label' => [
|
||||
Rule::requiredIf($request->tipe === LayoutForm::SECTION->value),
|
||||
'nullable', 'string'],
|
||||
]);
|
||||
|
||||
$form->update([...$validated,
|
||||
'updated_by' => auth()->user()->id
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Form basis data berhasil diubah.'
|
||||
]);
|
||||
}
|
||||
|
||||
public function destroy(string $tabelId, string $id): JsonResponse
|
||||
{
|
||||
Gate::authorize('super_admin');
|
||||
|
||||
$form = FormBasisData::where('tabel_id', $tabelId)->find($id);
|
||||
if (!$form) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Data form basis data tidak ditemukan.'
|
||||
], 404);
|
||||
}
|
||||
if ($form->form->count() > 0) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Tidak dapat menghapus formulir basis data yang memiliki formulir.'
|
||||
], 400);
|
||||
}
|
||||
$form->update([
|
||||
'deleted_by' => auth()->user()->id
|
||||
]);
|
||||
$form->delete();
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Form basis data berhasil dihapus.'
|
||||
], 200);
|
||||
}
|
||||
|
||||
public function generate(Request $request, string $tabelId): RedirectResponse
|
||||
{
|
||||
Gate::authorize('super_admin');
|
||||
|
||||
$tabel = TabelBasisData::find($tabelId);
|
||||
if (!$tabel) {
|
||||
return redirect()->route('tabel.formulir.index', $tabelId)->with('error', 'Tabel basis data tidak ditemukan.');
|
||||
}
|
||||
|
||||
DB::transaction(function () use ($tabel) {
|
||||
|
||||
FormBasisData::where('tabel_id', $tabel->id)->delete();
|
||||
|
||||
FormBasisData::create([
|
||||
'tabel_id' => $tabel->id,
|
||||
'tipe' => LayoutForm::SECTION,
|
||||
'section_label' => $tabel->label,
|
||||
'created_by' => auth()->user()->id,
|
||||
'updated_by' => auth()->user()->id
|
||||
]);
|
||||
|
||||
FormBasisData::create([
|
||||
'tabel_id' => $tabel->id,
|
||||
'tipe' => LayoutForm::HR_LINE,
|
||||
'created_by' => auth()->user()->id,
|
||||
'updated_by' => auth()->user()->id
|
||||
]);
|
||||
|
||||
$chunks = $tabel->kolom->chunk(4);
|
||||
|
||||
foreach ($chunks as $chunk) {
|
||||
|
||||
$row = FormBasisData::create([
|
||||
'tabel_id' => $tabel->id,
|
||||
'tipe' => LayoutForm::ROW,
|
||||
'created_by' => auth()->user()->id,
|
||||
'updated_by' => auth()->user()->id
|
||||
]);
|
||||
|
||||
foreach ($chunk as $kolom) {
|
||||
$column = FormBasisData::create([
|
||||
'tabel_id' => $tabel->id,
|
||||
'tipe' => LayoutForm::COLUMN,
|
||||
'column_width' => 3,
|
||||
'parent_id' => $row->id,
|
||||
'created_by' => auth()->user()->id,
|
||||
'updated_by' => auth()->user()->id
|
||||
]);
|
||||
|
||||
FormBasisData::create([
|
||||
'tabel_id' => $tabel->id,
|
||||
'tipe' => LayoutForm::VALUE,
|
||||
'parent_id' => $column->id,
|
||||
'kolom_id' => $kolom->id,
|
||||
'created_by' => auth()->user()->id,
|
||||
'updated_by' => auth()->user()->id
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return redirect()->route('tabel.formulir.index', $tabelId)->with('success', 'Formulir berhasil dibuat.');
|
||||
}
|
||||
|
||||
public function moveUp(Request $request, string $tabelId, string $id): JsonResponse
|
||||
{
|
||||
Gate::authorize('super_admin');
|
||||
|
||||
$current = FormBasisData::where('tabel_id', $tabelId)->find($id);
|
||||
if (!$current) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Data formulir tidak ditemukan.'
|
||||
], 404);
|
||||
}
|
||||
|
||||
$prev = FormBasisData::where('tabel_id', $tabelId)
|
||||
->where('urutan', '<', $current->urutan)
|
||||
->where('parent_id', $current->parent_id)
|
||||
->orderBy('urutan', 'desc')
|
||||
->first();
|
||||
|
||||
if ($prev) {
|
||||
// swap
|
||||
[$current->urutan, $prev->urutan] = [$prev->urutan, $current->urutan];
|
||||
$current->save();
|
||||
$prev->save();
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Formulir basis data berhasil diperbarui.'
|
||||
], 200);
|
||||
}
|
||||
|
||||
public function moveDown(Request $request, string $tabelId, string $id): JsonResponse
|
||||
{
|
||||
Gate::authorize('super_admin');
|
||||
|
||||
$current = FormBasisData::where('tabel_id', $tabelId)->find($id);
|
||||
if (!$current) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Data formulir tidak ditemukan.'
|
||||
], 404);
|
||||
}
|
||||
|
||||
$next = FormBasisData::where('tabel_id', $tabelId)
|
||||
->where('urutan', '>', $current->urutan)
|
||||
->where('parent_id', $current->parent_id)
|
||||
->orderBy('urutan', 'asc')
|
||||
->first();
|
||||
|
||||
if ($next) {
|
||||
// swap
|
||||
[$current->urutan, $next->urutan] = [$next->urutan, $current->urutan];
|
||||
$current->save();
|
||||
$next->save();
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Formulir basis data berhasil diperbarui.'
|
||||
], 200);
|
||||
}
|
||||
}
|
||||
@@ -145,6 +145,13 @@ class KolomBasisDataController extends Controller
|
||||
'is_browse' => ['nullable', 'boolean'],
|
||||
]);
|
||||
|
||||
if (!empty($validated['enum_opsi'])) {
|
||||
$validated['enum_opsi'] = json_decode($validated['enum_opsi'], true);
|
||||
}
|
||||
if (!empty($validated['validasi'])) {
|
||||
$validated['validasi'] = json_decode($validated['validasi'], true);
|
||||
}
|
||||
|
||||
$kolom->update([...$validated,
|
||||
'updated_by' => auth()->id(),
|
||||
]);
|
||||
@@ -188,7 +195,7 @@ class KolomBasisDataController extends Controller
|
||||
], 404);
|
||||
}
|
||||
|
||||
$prev = KolomBasisData::where('tabel_id', $current->tabel_id)
|
||||
$prev = KolomBasisData::where('tabel_id', $tabelId)
|
||||
->where('urutan', '<', $current->urutan)
|
||||
->orderBy('urutan', 'desc')
|
||||
->first();
|
||||
@@ -218,7 +225,7 @@ class KolomBasisDataController extends Controller
|
||||
], 404);
|
||||
}
|
||||
|
||||
$next = KolomBasisData::where('tabel_id', $current->tabel_id)
|
||||
$next = KolomBasisData::where('tabel_id', $tabelId)
|
||||
->where('urutan', '>', $current->urutan)
|
||||
->orderBy('urutan', 'asc')
|
||||
->first();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user