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') +
+
+
+
+
+
+
+ + + +
+

{{ $petaniSummary->sum('total') }}

+
+

Petani

+

+ {{ $petaniSummary->count('total') }} + komoditas utama +

+
+
+
+
+
+
+
+
+ + + +
+

{{ $lahanSummary->sum('luas_lahan') }}m2

+
+

Lahan

+

+ {{ $lahanSummary->count('total') }} + komoditas utama +

+
+
+
+
+
+
+
+
+ + + +
+

{{ $tanamanSummary->sum('total') }}

+
+

Tanaman Komoditas Utama

+
+ @foreach($komoditas as $k) +

+ {{ $tanamanSummary->where('komoditas_id', $k->id)->sum('total') }} + tanaman {{ $k->nama }} +

+ @endforeach +
+
+
+
+
+ +
+
+
+
+
+
Segmentasi Petani
+

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) }}% +
+
+
+
+
+
+
+
+
Segmentasi Petani Komoditas
+

berdasarkan mayoritas segmentasi

+
+
+
+ + + @foreach ($komoditas as $k) + where('komoditas_id', $k->id) + ->sortByDesc('total') + ->first(); + ?> + + + + + + + @endforeach + +
+
{{ $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 }}% +
+
+
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/layout/sidebar.blade.php b/resources/views/layout/sidebar.blade.php index 1b2d065..cb24fbb 100644 --- a/resources/views/layout/sidebar.blade.php +++ b/resources/views/layout/sidebar.blade.php @@ -56,6 +56,13 @@ + @endif diff --git a/routes/web.php b/routes/web.php index 7d08cbb..0744a06 100644 --- a/routes/web.php +++ b/routes/web.php @@ -33,6 +33,9 @@ Route::middleware('auth') Route::get('/dashboard/produktivitas', [App\Http\Controllers\Web\Dashboard\SummaryController::class, 'produktivitas'])->name('dashboard.produktivitas'); + // Dashboard + Route::get('/dashboard/petani', [App\Http\Controllers\Web\Dashboard\ProfilPetaniController::class, 'index'])->name('dashboard.petani'); + Route::get('/UserProfile', [App\Http\Controllers\Web\Konfigurasi\ProfileController::class, 'index'])->name('userProfile.index'); Route::get('/UserProfile/security', [App\Http\Controllers\Web\Konfigurasi\ProfileController::class, 'security'])->name('userProfile.security');