solve jumlah lahan dan tanaman
This commit is contained in:
@@ -111,15 +111,9 @@ class PetaniController extends Controller
|
||||
$desaOptions = $request->filled('kecamatan_id')
|
||||
? DesaKelurahan::select('id', 'nama')->where('kecamatan_id', $request->kecamatan_id)->orderBy('nama')->get()
|
||||
: collect();
|
||||
$lahanQuery = Lahan::whereIn('petani_id', $summaryPetaniIds)
|
||||
->when(
|
||||
$request->filled('komoditas_id'),
|
||||
fn ($query) => $query->where('komoditas_id', $request->komoditas_id),
|
||||
fn ($query) => $query->whereIn('komoditas_id', $komoditas->pluck('id'))
|
||||
);
|
||||
$lahanIds = (clone $lahanQuery)->pluck('id');
|
||||
$totalLuasLahan = (clone $lahanQuery)->sum('luas_lahan');
|
||||
$totalTanaman = Tanaman::whereIn('lahan_id', $lahanIds)->count();
|
||||
$totalLahan = Lahan::count();
|
||||
$totalLuasLahan = Lahan::sum('luas_lahan');
|
||||
$totalTanaman = Tanaman::count();
|
||||
|
||||
$case = "
|
||||
CASE
|
||||
@@ -146,6 +140,7 @@ class PetaniController extends Controller
|
||||
'desaOptions',
|
||||
'filters',
|
||||
'skor',
|
||||
'totalLahan',
|
||||
'totalLuasLahan',
|
||||
'totalTanaman',
|
||||
'showFasilitatorColumn'
|
||||
|
||||
Reference in New Issue
Block a user