diff --git a/app/Http/Controllers/Web/Dashboard/ProfilPetaniController.php b/app/Http/Controllers/Web/Dashboard/ProfilPetaniController.php new file mode 100644 index 0000000..6d88699 --- /dev/null +++ b/app/Http/Controllers/Web/Dashboard/ProfilPetaniController.php @@ -0,0 +1,87 @@ +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(); + + return view('dashboard.petani', compact('title', + 'komoditas', + 'petaniSummary', + 'lahanSummary', + 'tanamanSummary', + 'skorSummary', + 'skorKomoditasSummary' + )); + } +} diff --git a/resources/views/dashboard/petani.blade.php b/resources/views/dashboard/petani.blade.php new file mode 100644 index 0000000..3cc247b --- /dev/null +++ b/resources/views/dashboard/petani.blade.php @@ -0,0 +1,215 @@ +@extends('layout.main') + +@section('content') +
Petani
++ {{ $petaniSummary->count('total') }} + komoditas utama +
+Lahan
++ {{ $lahanSummary->count('total') }} + komoditas utama +
+Tanaman Komoditas Utama
++ {{ $tanamanSummary->where('komoditas_id', $k->id)->sum('total') }} + tanaman {{ $k->nama }} +
+ @endforeach +untuk semua komoditas
+|
+
+
+
+
+
+
+
+ Penggerak (4.0 - 5.0)+ + |
+ + {{ $skorSummary->where('segmentasi', 'Penggerak')->sum('total') }} petani + | ++ {{ number_format(($skorSummary->where('segmentasi', 'Penggerak')->sum('total') / $petaniSummary->sum('total')) * 100, 2) }}% + | +
|
+
+
+
+
+
+
+
+ Perintis (3.0 - 3.9)+ + |
+ + {{ $skorSummary->where('segmentasi', 'Perintis')->sum('total') }} petani + | ++ {{ number_format(($skorSummary->where('segmentasi', 'Perintis')->sum('total') / $petaniSummary->sum('total')) * 100, 2) }}% + | +
|
+
+
+
+
+
+
+
+ Pemerhati (2.0 - 2.9)+ + |
+ + {{ $skorSummary->where('segmentasi', 'Pemerhati')->sum('total') }} petani + | ++ {{ number_format(($skorSummary->where('segmentasi', 'Pemerhati')->sum('total') / $petaniSummary->sum('total')) * 100, 2) }}% + | +
|
+
+
+
+
+
+
+
+ Pemula (1.0 - 1.9)+ + |
+ + {{ $skorSummary->where('segmentasi', 'Pemula')->sum('total') }} petani + | ++ {{ number_format(($skorSummary->where('segmentasi', 'Pemula')->sum('total') / $petaniSummary->sum('total')) * 100, 2) }}% + | +
berdasarkan mayoritas segmentasi
+
+ {{ $k->nama }}+ |
+ + @if(isset($max)) + @if($max->segmentasi == 'Penggerak') + Petani Penggerak + @elseif($max->segmentasi == 'Perintis') + Petani Perintis + @elseif($max->segmentasi == 'Pemerhati') + Petani Pemerhati + @elseif($max->segmentasi == 'Pemula') + Petani Pemula + @else + Belum Lengkap + @endif + @else + Belum Ada + @endif + | ++ {{ isset($max) ? $max->total : 0 }} Petani + | ++ {{ isset($max) ? number_format(($max->total / $petaniSummary->sum('total')) * 100, 2) : 0 }}% + | +