Update Kelompok Tani
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum JenisKelompokTani: string
|
||||
{
|
||||
case POKTAN = 'Kelompok Tani (Poktan)';
|
||||
case KWT = 'Kelompok Wanita Tani (KWT)';
|
||||
case GAPOKTAN = 'Gabungan Kelompok Tani (Gapoktan)';
|
||||
case PEMUDA_TANI = 'Kelompok Pemuda Tani';
|
||||
case ASOSIASI = 'Asosiasi Petani';
|
||||
case LAINNYA = 'Lainnya';
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->mapWithKeys(fn (self $jenis) => [$jenis->value => $jenis->value])->all();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum StatusLegalitasKelompokTani: string
|
||||
{
|
||||
case BELUM_ADA = 'Belum ada SK/dokumen apa pun';
|
||||
case PROSES = 'Sedang proses pengajuan';
|
||||
case SK_DESA_KECAMATAN = 'Sudah ada SK dari desa/kecamatan';
|
||||
case SK_DINAS_KABUPATEN = 'Sudah ada SK dan terdaftar di Dinas/Kabupaten';
|
||||
case TIDAK_TAHU = 'Tidak tahu';
|
||||
|
||||
public static function options(): array
|
||||
{
|
||||
return collect(self::cases())->mapWithKeys(fn (self $status) => [$status->value => $status->value])->all();
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,9 @@
|
||||
namespace App\Http\Controllers\Web\Produktivitas;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Produktivitas\IndexKelompokTaniRequest;
|
||||
use App\Services\Produktivitas\KelompokTaniService;
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\Str;
|
||||
@@ -32,94 +35,10 @@ class SurveyKelompokTaniController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function index(Request $request)
|
||||
public function index(IndexKelompokTaniRequest $request): View
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'search' => ['nullable', 'string', 'max:255'],
|
||||
'kabupaten_kota_id' => ['nullable', 'integer', 'exists:master_kabupaten_kota,id'],
|
||||
'kecamatan_id' => ['nullable', 'integer', 'exists:master_kecamatan,id'],
|
||||
'desa_kelurahan_id' => ['nullable', 'integer', 'exists:master_desa_kelurahan,id'],
|
||||
'komoditas_id' => ['nullable', 'integer', 'exists:master_komoditas,id'],
|
||||
'jenis_kelompok' => ['nullable', 'string', 'max:50'],
|
||||
'sort_by' => ['nullable', 'string'],
|
||||
'per_page' => ['nullable', 'integer', 'in:10,25'],
|
||||
]);
|
||||
|
||||
$defaultKabupaten = KabupatenKota::select('id', 'nama')
|
||||
->whereRaw('lower(nama) like ?', ['%ngada%'])->orderBy('nama')->first();
|
||||
$allowedSorts = ['nama_asc', 'nama_desc', 'anggota_desc', 'anggota_asc'];
|
||||
$filters = [
|
||||
'search' => $validated['search'] ?? null,
|
||||
'kabupaten_kota_id' => $validated['kabupaten_kota_id'] ?? $defaultKabupaten?->id,
|
||||
'kecamatan_id' => $validated['kecamatan_id'] ?? null,
|
||||
'desa_kelurahan_id' => $validated['desa_kelurahan_id'] ?? null,
|
||||
'komoditas_id' => $validated['komoditas_id'] ?? null,
|
||||
'jenis_kelompok' => $validated['jenis_kelompok'] ?? null,
|
||||
'sort_by' => in_array($validated['sort_by'] ?? null, $allowedSorts, true)
|
||||
? $validated['sort_by'] : null,
|
||||
];
|
||||
|
||||
$query = KelompokTani::query()
|
||||
->when(filled($filters['search']), function ($query) use ($filters) {
|
||||
$search = '%' . Str::lower($filters['search']) . '%';
|
||||
$query->where(function ($query) use ($search) {
|
||||
$query->whereRaw('lower(nama_kelompok) like ?', [$search])
|
||||
->orWhereRaw('lower(nama_responden) like ?', [$search]);
|
||||
});
|
||||
})
|
||||
->when($filters['kabupaten_kota_id'], function ($query, $id) {
|
||||
$query->whereHas('desaKelurahan.kecamatan', fn ($query) => $query->where('kabupaten_kota_id', $id));
|
||||
})
|
||||
->when($filters['kecamatan_id'], function ($query, $id) {
|
||||
$query->whereHas('desaKelurahan', fn ($query) => $query->where('kecamatan_id', $id));
|
||||
})
|
||||
->when($filters['desa_kelurahan_id'], fn ($query, $id) => $query->where('desa_kelurahan_id', $id))
|
||||
->when($filters['komoditas_id'], function ($query, $id) {
|
||||
$query->where(function ($query) use ($id) {
|
||||
$query->whereJsonContains('komoditas_id', (string) $id)
|
||||
->orWhereJsonContains('komoditas_id', (int) $id);
|
||||
});
|
||||
})
|
||||
->when($filters['jenis_kelompok'], fn ($query, $jenis) => $query->where('jenis_kelompok', $jenis));
|
||||
|
||||
$summary = (clone $query)->selectRaw('
|
||||
COUNT(*) AS total_kelompok,
|
||||
COUNT(DISTINCT jenis_kelompok) AS total_jenis,
|
||||
COALESCE(SUM(jumlah_pengurus), 0) AS total_pengurus,
|
||||
COALESCE(SUM(jumlah_pengurus_aktif), 0) AS pengurus_aktif,
|
||||
COALESCE(SUM(jumlah_anggota_terdaftar), 0) AS total_anggota,
|
||||
COALESCE(SUM(jumlah_anggota_aktif), 0) AS anggota_aktif
|
||||
')->first();
|
||||
|
||||
match ($filters['sort_by']) {
|
||||
'nama_asc' => $query->orderBy('nama_kelompok'),
|
||||
'nama_desc' => $query->orderByDesc('nama_kelompok'),
|
||||
'anggota_desc' => $query->orderByRaw('COALESCE(jumlah_anggota_terdaftar, 0) DESC'),
|
||||
'anggota_asc' => $query->orderByRaw('COALESCE(jumlah_anggota_terdaftar, 0) ASC'),
|
||||
default => $query->latest(),
|
||||
};
|
||||
|
||||
$perPage = (int) ($validated['per_page'] ?? 10);
|
||||
$kelompokTani = $query->with('desaKelurahan.kecamatan')->orderByDesc('id')
|
||||
->paginate($perPage)->appends([...$filters, 'per_page' => $perPage]);
|
||||
$selectedKabupaten = $filters['kabupaten_kota_id']
|
||||
? KabupatenKota::select('id', 'nama')->find($filters['kabupaten_kota_id']) : null;
|
||||
$kecamatanOptions = $filters['kabupaten_kota_id']
|
||||
? Kecamatan::select('id', 'nama')->where('kabupaten_kota_id', $filters['kabupaten_kota_id'])->orderBy('nama')->get()
|
||||
: collect();
|
||||
$desaOptions = $filters['kecamatan_id']
|
||||
? DesaKelurahan::select('id', 'nama')->where('kecamatan_id', $filters['kecamatan_id'])->orderBy('nama')->get()
|
||||
: collect();
|
||||
$komoditasOptions = Komoditas::select('id', 'nama')->orderBy('nama')->get();
|
||||
$jenisKelompokOptions = KelompokTani::query()->whereNotNull('jenis_kelompok')
|
||||
->where('jenis_kelompok', '!=', '')->distinct()->orderBy('jenis_kelompok')->pluck('jenis_kelompok');
|
||||
|
||||
return view('produktivitas.survey-kelompok-tani.index', compact(
|
||||
'kelompokTani', 'summary', 'filters', 'selectedKabupaten',
|
||||
'kecamatanOptions', 'desaOptions', 'komoditasOptions', 'jenisKelompokOptions'
|
||||
));
|
||||
return view('produktivitas.survey-kelompok-tani.index', app(KelompokTaniService::class)->indexData($request->validated()));
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$this->authorizeAccess();
|
||||
@@ -129,6 +48,7 @@ class SurveyKelompokTaniController extends Controller
|
||||
|
||||
return view('produktivitas.survey-kelompok-tani.add', [
|
||||
...compact('provinsi', 'komoditas'),
|
||||
'ringkasanProfil' => app(KelompokTaniService::class)->profileSummary(),
|
||||
...$this->profileLocationOptions(),
|
||||
]);
|
||||
}
|
||||
@@ -178,15 +98,18 @@ class SurveyKelompokTaniController extends Controller
|
||||
public function edit(Request $request, KelompokTani $kelompokTani)
|
||||
{
|
||||
$this->authorizeAccess();
|
||||
$ringkasanProfil = app(KelompokTaniService::class)->profileSummary($kelompokTani);
|
||||
|
||||
return match ($request->query('section', 'identitas')) {
|
||||
'kelembagaan' => view('produktivitas.survey-kelompok-tani.kelembagaan', compact('kelompokTani')),
|
||||
'kelembagaan' => view('produktivitas.survey-kelompok-tani.kelembagaan', compact('kelompokTani', 'ringkasanProfil')),
|
||||
'aktivitas-fungsi' => view('produktivitas.survey-kelompok-tani.aktivitas-fungsi', [
|
||||
'kelompokTani' => $kelompokTani->loadMissing(['aset', 'bantuan']),
|
||||
'ringkasanProfil' => $ringkasanProfil,
|
||||
]),
|
||||
'sosial-konflik' => view('produktivitas.survey-kelompok-tani.sosial-konflik', compact('kelompokTani')),
|
||||
'sosial-konflik' => view('produktivitas.survey-kelompok-tani.sosial-konflik', compact('kelompokTani', 'ringkasanProfil')),
|
||||
default => view('produktivitas.survey-kelompok-tani.edit', [
|
||||
'kelompokTani' => $kelompokTani->loadMissing('pengurus'),
|
||||
'ringkasanProfil' => $ringkasanProfil,
|
||||
'provinsi' => Provinsi::orderBy('kode', 'asc')->get(),
|
||||
'komoditas' => Komoditas::where('is_utama', true)->get(),
|
||||
...$this->profileLocationOptions($kelompokTani),
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Produktivitas;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
class IndexKelompokTaniRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Gate::any(['super_admin', 'admin', 'enumerator']);
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'search' => ['nullable', 'string', 'max:255'],
|
||||
'kabupaten_kota_id' => ['bail', 'nullable', 'integer', 'exists:master_kabupaten_kota,id'],
|
||||
'kecamatan_id' => ['bail', 'nullable', 'integer', 'exists:master_kecamatan,id'],
|
||||
'desa_kelurahan_id' => ['bail', 'nullable', 'integer', 'exists:master_desa_kelurahan,id'],
|
||||
'komoditas_id' => ['bail', 'nullable', 'integer', 'exists:master_komoditas,id'],
|
||||
'jenis_kelompok' => ['nullable', 'string', 'max:50'],
|
||||
'status_legalitas' => ['nullable', 'string', 'max:50'],
|
||||
'sort_by' => ['nullable', 'string', 'max:50'],
|
||||
'per_page' => ['nullable', 'integer', 'in:10,25'],
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'integer' => ':attribute harus berupa angka bulat.',
|
||||
'exists' => ':attribute tidak ditemukan.',
|
||||
'string' => ':attribute harus berupa teks.',
|
||||
'max' => ':attribute terlalu panjang.',
|
||||
'in' => 'Pilihan :attribute tidak valid.',
|
||||
];
|
||||
}
|
||||
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'search' => 'Pencarian',
|
||||
'kabupaten_kota_id' => 'Kabupaten/Kota',
|
||||
'kecamatan_id' => 'Kecamatan',
|
||||
'desa_kelurahan_id' => 'Desa/Kelurahan',
|
||||
'komoditas_id' => 'Komoditas',
|
||||
'jenis_kelompok' => 'Jenis kelompok',
|
||||
'status_legalitas' => 'Status SK/Dokumen Pendaftaran',
|
||||
'sort_by' => 'Urutan data',
|
||||
'per_page' => 'Jumlah data per halaman',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
use App\Models\Wilayah\DesaKelurahan;
|
||||
use App\Models\User;
|
||||
|
||||
class KelompokTani extends Model
|
||||
{
|
||||
@@ -125,6 +126,11 @@ class KelompokTani extends Model
|
||||
return $this->belongsTo(DesaKelurahan::class, 'desa_kelurahan_id');
|
||||
}
|
||||
|
||||
public function creator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'created_by');
|
||||
}
|
||||
|
||||
public function pengurus()
|
||||
{
|
||||
return $this->hasMany(PengurusKelompokTani::class, 'survey_kelompok_tani_id');
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Produktivitas;
|
||||
|
||||
use App\Enums\JenisKelompokTani;
|
||||
use App\Enums\StatusLegalitasKelompokTani;
|
||||
use App\Models\Pertanian\KelompokTani;
|
||||
use App\Models\Pertanian\Komoditas;
|
||||
use App\Models\Wilayah\DesaKelurahan;
|
||||
use App\Models\Wilayah\KabupatenKota;
|
||||
use App\Models\Wilayah\Kecamatan;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class KelompokTaniService
|
||||
{
|
||||
public function profileSummary(?KelompokTani $kelompokTani = null): array
|
||||
{
|
||||
$kelompokTani?->loadMissing('desaKelurahan.kecamatan.kabupatenKota');
|
||||
$desa = $kelompokTani?->desaKelurahan;
|
||||
$statusSk = $kelompokTani?->status_legalitas;
|
||||
$memilikiSk = in_array($statusSk, KelompokTani::STATUS_LEGALITAS_DENGAN_SK, true);
|
||||
$komoditas = $kelompokTani?->komoditas_id
|
||||
? Komoditas::whereIn('id', $kelompokTani->komoditas_id)->orderBy('nama')->pluck('nama')->unique()->values()->all()
|
||||
: [];
|
||||
$tanggalPerubahan = collect([$kelompokTani?->updated_at ?? $kelompokTani?->created_at])->filter();
|
||||
if ($kelompokTani?->exists) {
|
||||
foreach (['pengurus', 'aset', 'bantuan'] as $relation) {
|
||||
// Penghapusan data bagian juga termasuk pembaruan profil kelompok.
|
||||
$tanggal = $kelompokTani->{$relation}()->withTrashed()->max(DB::raw('COALESCE(updated_at, created_at)'));
|
||||
if ($tanggal) {
|
||||
$tanggalPerubahan->push(Carbon::parse($tanggal));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'judul' => $kelompokTani ? ($kelompokTani->nama_kelompok ?: 'Profil Kelompok Tani') : 'Profil Kelompok Tani Baru',
|
||||
'lokasi' => collect([$desa?->nama, $desa?->kecamatan?->nama, $desa?->kecamatan?->kabupatenKota?->nama])
|
||||
->filter()->implode(' · ') ?: 'Lokasi belum terisi',
|
||||
'jenis' => $kelompokTani?->jenis_kelompok ?: 'Belum terisi',
|
||||
'legalitas' => [
|
||||
'label' => $memilikiSk ? 'Sudah ada SK' : ($statusSk ?: 'Belum terisi'),
|
||||
'detail' => $statusSk ?: 'Belum terisi',
|
||||
'warna' => $memilikiSk ? 'success' : 'secondary',
|
||||
],
|
||||
'pengurus' => $kelompokTani?->jumlah_pengurus !== null ? number_format($kelompokTani->jumlah_pengurus, 0, ',', '.') : 'Belum terisi',
|
||||
'anggota' => $kelompokTani?->jumlah_anggota_terdaftar !== null ? number_format($kelompokTani->jumlah_anggota_terdaftar, 0, ',', '.') : 'Belum terisi',
|
||||
'komoditas' => $komoditas,
|
||||
'responden' => $kelompokTani?->nama_responden ?: 'Belum terisi',
|
||||
'jabatan' => $kelompokTani?->jabatan_responden ?: 'Belum terisi',
|
||||
'kontak' => $kelompokTani?->kontak_responden ?: 'Belum terisi',
|
||||
'tahun_berdiri' => $kelompokTani?->tahun_berdiri ?: 'Belum terisi',
|
||||
'diperbarui' => $tanggalPerubahan->sortByDesc(fn ($tanggal) => $tanggal->getTimestamp())->first(),
|
||||
];
|
||||
}
|
||||
|
||||
public function indexData(array $validated): array
|
||||
{
|
||||
$defaultKabupaten = KabupatenKota::select('id', 'nama')
|
||||
->whereRaw('lower(nama) like ?', ['%ngada%'])->orderBy('nama')->first();
|
||||
$filters = [
|
||||
'search' => $validated['search'] ?? null,
|
||||
'kabupaten_kota_id' => $validated['kabupaten_kota_id'] ?? $defaultKabupaten?->id,
|
||||
'kecamatan_id' => $validated['kecamatan_id'] ?? null,
|
||||
'desa_kelurahan_id' => $validated['desa_kelurahan_id'] ?? null,
|
||||
'komoditas_id' => $validated['komoditas_id'] ?? null,
|
||||
'jenis_kelompok' => $validated['jenis_kelompok'] ?? null,
|
||||
'status_legalitas' => $validated['status_legalitas'] ?? null,
|
||||
'sort_by' => in_array($validated['sort_by'] ?? null, ['nama_asc', 'nama_desc', 'anggota_desc', 'anggota_asc'], true)
|
||||
? $validated['sort_by'] : null,
|
||||
];
|
||||
|
||||
$query = KelompokTani::query()
|
||||
->when(filled($filters['search']), function ($query) use ($filters) {
|
||||
$search = '%'.Str::lower($filters['search']).'%';
|
||||
$query->where(function ($query) use ($search) {
|
||||
$query->whereRaw('lower(nama_kelompok) like ?', [$search])
|
||||
->orWhereRaw('lower(nama_responden) like ?', [$search])
|
||||
->orWhereHas('desaKelurahan', function ($query) use ($search) {
|
||||
$query->where(function ($query) use ($search) {
|
||||
$query->whereRaw('lower(nama) like ?', [$search])
|
||||
->orWhereHas('kecamatan', fn ($query) => $query->whereRaw('lower(nama) like ?', [$search]));
|
||||
});
|
||||
});
|
||||
});
|
||||
})
|
||||
->when($filters['kabupaten_kota_id'], fn ($query, $id) => $query
|
||||
->whereHas('desaKelurahan.kecamatan', fn ($query) => $query->where('kabupaten_kota_id', $id)))
|
||||
->when($filters['kecamatan_id'], fn ($query, $id) => $query
|
||||
->whereHas('desaKelurahan', fn ($query) => $query->where('kecamatan_id', $id)))
|
||||
->when($filters['desa_kelurahan_id'], fn ($query, $id) => $query->where('desa_kelurahan_id', $id))
|
||||
->when($filters['komoditas_id'], fn ($query, $id) => $query->where(function ($query) use ($id) {
|
||||
$query->whereJsonContains('komoditas_id', (string) $id)->orWhereJsonContains('komoditas_id', (int) $id);
|
||||
}))
|
||||
->when($filters['jenis_kelompok'], function ($query, $value) {
|
||||
if ($value === JenisKelompokTani::LAINNYA->value) {
|
||||
$jenisStandar = array_diff(JenisKelompokTani::options(), [JenisKelompokTani::LAINNYA->value]);
|
||||
$query->whereNotNull('jenis_kelompok')->where('jenis_kelompok', '!=', '')->whereNotIn('jenis_kelompok', $jenisStandar);
|
||||
} else {
|
||||
$query->where('jenis_kelompok', $value);
|
||||
}
|
||||
})
|
||||
->when($filters['status_legalitas'], fn ($query, $value) => $query->where('status_legalitas', $value));
|
||||
|
||||
$summary = (clone $query)->selectRaw('
|
||||
COUNT(*) AS total_kelompok,
|
||||
COUNT(DISTINCT desa_kelurahan_id) AS total_desa,
|
||||
COUNT(DISTINCT jenis_kelompok) AS total_jenis,
|
||||
COALESCE(SUM(jumlah_pengurus), 0) AS total_pengurus,
|
||||
COALESCE(SUM(jumlah_pengurus_aktif), 0) AS pengurus_aktif,
|
||||
COALESCE(SUM(jumlah_anggota_terdaftar), 0) AS total_anggota,
|
||||
COALESCE(SUM(jumlah_anggota_aktif), 0) AS anggota_aktif
|
||||
')->first();
|
||||
$summary->memiliki_sk = (clone $query)->whereIn('status_legalitas', KelompokTani::STATUS_LEGALITAS_DENGAN_SK)->count();
|
||||
|
||||
match ($filters['sort_by']) {
|
||||
'nama_asc' => $query->orderBy('nama_kelompok'),
|
||||
'nama_desc' => $query->orderByDesc('nama_kelompok'),
|
||||
'anggota_desc' => $query->orderByRaw('COALESCE(jumlah_anggota_terdaftar, 0) DESC'),
|
||||
'anggota_asc' => $query->orderByRaw('COALESCE(jumlah_anggota_terdaftar, 0) ASC'),
|
||||
default => $query->latest(),
|
||||
};
|
||||
|
||||
$showEnumerator = Gate::any(['super_admin', 'admin']);
|
||||
$query->with('desaKelurahan.kecamatan');
|
||||
if ($showEnumerator) {
|
||||
$query->with('creator:id,name');
|
||||
}
|
||||
$perPage = (int) ($validated['per_page'] ?? 10);
|
||||
$kelompokTani = $query->orderByDesc('id')->paginate($perPage)->appends([...$filters, 'per_page' => $perPage]);
|
||||
$komoditasOptions = Komoditas::select('id', 'nama')->orderBy('nama')->get();
|
||||
$komoditasById = $komoditasOptions->keyBy('id');
|
||||
$ringkasanKelompok = $kelompokTani->getCollection()->mapWithKeys(function (KelompokTani $item) use ($komoditasById) {
|
||||
$memilikiSk = in_array($item->status_legalitas, KelompokTani::STATUS_LEGALITAS_DENGAN_SK, true);
|
||||
|
||||
return [$item->id => [
|
||||
'lokasi' => collect([$item->desaKelurahan?->nama, $item->desaKelurahan?->kecamatan?->nama])
|
||||
->filter()->implode(' · ') ?: 'Lokasi belum terisi',
|
||||
'komoditas' => collect($item->komoditas_id ?? [])->map(fn ($id) => $komoditasById->get($id)?->nama)->filter()->unique()->values()->all(),
|
||||
'legalitas' => [
|
||||
'label' => $memilikiSk ? 'Sudah ada SK' : ($item->status_legalitas ?: 'Belum terisi'),
|
||||
'warna' => $memilikiSk ? 'success' : 'secondary',
|
||||
],
|
||||
]];
|
||||
});
|
||||
|
||||
$selectedKabupaten = $filters['kabupaten_kota_id'] ? KabupatenKota::select('id', 'nama')->find($filters['kabupaten_kota_id']) : null;
|
||||
$kecamatanOptions = $filters['kabupaten_kota_id']
|
||||
? Kecamatan::select('id', 'nama')->where('kabupaten_kota_id', $filters['kabupaten_kota_id'])->orderBy('nama')->get() : collect();
|
||||
$desaOptions = $filters['kecamatan_id']
|
||||
? DesaKelurahan::select('id', 'nama')->where('kecamatan_id', $filters['kecamatan_id'])->orderBy('nama')->get() : collect();
|
||||
$jenisKelompokOptions = collect(JenisKelompokTani::options())->values();
|
||||
$statusLegalitasOptions = collect(StatusLegalitasKelompokTani::options())->values();
|
||||
|
||||
return compact('kelompokTani', 'summary', 'filters', 'ringkasanKelompok', 'showEnumerator', 'selectedKabupaten',
|
||||
'kecamatanOptions', 'desaOptions', 'komoditasOptions', 'jenisKelompokOptions', 'statusLegalitasOptions');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user