revisi jumlahpetani
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Web\Dashboard;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
use App\Models\Pertanian\Petani;
|
||||
use App\Models\Pertanian\Komoditas;
|
||||
@@ -15,6 +16,10 @@ class DemografiPetaniController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
if (!Gate::any(['super_admin', 'admin', 'fasilitator'])) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$petaniCounts = Petani::selectRaw("
|
||||
COUNT(*) as total,
|
||||
COUNT(*) FILTER (WHERE jenis_kelamin = true) as laki,
|
||||
|
||||
@@ -103,7 +103,8 @@ class IndikatorPertanianController extends Controller
|
||||
private function summaryData(array $filters): array
|
||||
{
|
||||
$totalPetani = $this->applyPetaniFilters(Petani::query(), $filters)->count();
|
||||
$totalLuasLahan = ((float) $this->applyLahanFilters(Lahan::query(), $filters)->sum('luas_lahan')) / 10000;
|
||||
// $totalLuasLahan = ((float) $this->applyLahanFilters(Lahan::query(), $filters)->sum('luas_lahan')) / 10000;
|
||||
$totalLuasLahan = $this->applyLahanFilters(Lahan::has('petani'), $filters)->sum('luas_lahan');
|
||||
$rataRataLuasLahan = $totalPetani > 0
|
||||
? $totalLuasLahan / $totalPetani
|
||||
: 0;
|
||||
|
||||
@@ -63,7 +63,8 @@ class SurveyPetaniController extends Controller
|
||||
->orderByDesc('petani_count')
|
||||
->get();
|
||||
|
||||
$totalPetani = (int) $komoditasCollection->sum('petani_count');
|
||||
// $totalPetani = (int) $komoditasCollection->sum('petani_count');
|
||||
$totalPetani = Petani::count();
|
||||
$circumference = 2 * pi() * 46;
|
||||
|
||||
$komoditas = $komoditasCollection
|
||||
@@ -144,8 +145,9 @@ class SurveyPetaniController extends Controller
|
||||
|
||||
// Ringkasan lahan
|
||||
|
||||
$totalLuasLahan = ((float) Lahan::query()
|
||||
->sum('luas_lahan')) / 10000;
|
||||
// $totalLuasLahan = ((float) Lahan::query()
|
||||
// ->sum('luas_lahan')) / 10000;
|
||||
$totalLuasLahan = Lahan::has('petani')->sum('luas_lahan');
|
||||
|
||||
// Jumlah tanaman berdasarkan komoditas petani
|
||||
|
||||
|
||||
Reference in New Issue
Block a user