profil petani dashboard

This commit is contained in:
2026-07-15 01:06:10 +07:00
parent 30196278d7
commit 002d6044b4
2 changed files with 18 additions and 17 deletions
@@ -17,7 +17,7 @@ class ProfilPetaniController extends Controller
{ {
public function index() public function index()
{ {
if (!Gate::allows('super_admin') && !Gate::allows('admin')) { if (!Gate::any(['super_admin', 'admin', 'fasilitator'])) {
abort(403); abort(403);
} }
$title = 'Dashboard Profil Petani'; $title = 'Dashboard Profil Petani';
@@ -35,8 +35,8 @@ class ProfilPetaniController extends Controller
->get(); ->get();
$lahanSummary = Lahan::select( $lahanSummary = Lahan::select(
'komoditas_id', 'komoditas_id',
DB::raw('COUNT(*) as total', DB::raw('COUNT(*) as total'),
DB::raw('SUM(luas_lahan) as luas_lahan')) DB::raw('SUM(luas_lahan) as luas_lahan')
) )
->whereIn('petani_id', $petani) ->whereIn('petani_id', $petani)
->groupBy('komoditas_id') ->groupBy('komoditas_id')
+15 -14
View File
@@ -31,7 +31,7 @@
<i class="icon-base ti tabler-trees icon-28px"></i> <i class="icon-base ti tabler-trees icon-28px"></i>
</span> </span>
</div> </div>
<h4 class="mb-0">{{ $lahanSummary->sum('luas_lahan') }}m<sup>2</sup></h4> <h4 class="mb-0">{{ number_format($lahanSummary->sum('luas_lahan'), 0, ',', '.') }}m<sup>2</sup></h4>
</div> </div>
<p class="mb-1">Lahan</p> <p class="mb-1">Lahan</p>
<p class="mb-0"> <p class="mb-0">
@@ -91,10 +91,10 @@
</div> </div>
</td> </td>
<td class="text-end pe-0"> <td class="text-end pe-0">
<span>{{ $skorSummary->where('segmentasi', 'Penggerak')->sum('total') }} petani</span> <span>{{ $skorSummary->where('segmen', 'Penggerak')->sum('total') }} petani</span>
</td> </td>
<td class="text-end pe-0"> <td class="text-end pe-0">
<span>{{ number_format(($skorSummary->where('segmentasi', 'Penggerak')->sum('total') / $petaniSummary->sum('total')) * 100, 2) }}%</span> <span>{{ number_format(($skorSummary->where('segmen', 'Penggerak')->sum('total') / $petaniSummary->sum('total')) * 100, 2) }}%</span>
</td> </td>
</tr> </tr>
<tr> <tr>
@@ -110,10 +110,10 @@
</div> </div>
</td> </td>
<td class="text-end pe-0"> <td class="text-end pe-0">
<span>{{ $skorSummary->where('segmentasi', 'Perintis')->sum('total') }} petani</span> <span>{{ $skorSummary->where('segmen', 'Perintis')->sum('total') }} petani</span>
</td> </td>
<td class="text-end pe-0"> <td class="text-end pe-0">
<span>{{ number_format(($skorSummary->where('segmentasi', 'Perintis')->sum('total') / $petaniSummary->sum('total')) * 100, 2) }}%</span> <span>{{ number_format(($skorSummary->where('segmen', 'Perintis')->sum('total') / $petaniSummary->sum('total')) * 100, 2) }}%</span>
</td> </td>
</tr> </tr>
<tr> <tr>
@@ -129,10 +129,10 @@
</div> </div>
</td> </td>
<td class="text-end pe-0"> <td class="text-end pe-0">
<span>{{ $skorSummary->where('segmentasi', 'Pemerhati')->sum('total') }} petani</span> <span>{{ $skorSummary->where('segmen', 'Pemerhati')->sum('total') }} petani</span>
</td> </td>
<td class="text-end pe-0"> <td class="text-end pe-0">
<span>{{ number_format(($skorSummary->where('segmentasi', 'Pemerhati')->sum('total') / $petaniSummary->sum('total')) * 100, 2) }}%</span> <span>{{ number_format(($skorSummary->where('segmen', 'Pemerhati')->sum('total') / $petaniSummary->sum('total')) * 100, 2) }}%</span>
</td> </td>
</tr> </tr>
<tr> <tr>
@@ -148,10 +148,10 @@
</div> </div>
</td> </td>
<td class="text-end pe-0"> <td class="text-end pe-0">
<span>{{ $skorSummary->where('segmentasi', 'Pemula')->sum('total') }} petani</span> <span>{{ $skorSummary->where('segmen', 'Pemula')->sum('total') }} petani</span>
</td> </td>
<td class="text-end pe-0"> <td class="text-end pe-0">
<span>{{ number_format(($skorSummary->where('segmentasi', 'Pemula')->sum('total') / $petaniSummary->sum('total')) * 100, 2) }}%</span> <span>{{ number_format(($skorSummary->where('segmen', 'Pemula')->sum('total') / $petaniSummary->sum('total')) * 100, 2) }}%</span>
</td> </td>
</tr> </tr>
</tbody> </tbody>
@@ -173,6 +173,7 @@
@foreach ($komoditas as $k) @foreach ($komoditas as $k)
<?php <?php
$max = $skorKomoditasSummary->where('komoditas_id', $k->id) $max = $skorKomoditasSummary->where('komoditas_id', $k->id)
->whereIn('segmen', ['Penggerak', 'Perintis', 'Pemerhati', 'Pemula'])
->sortByDesc('total') ->sortByDesc('total')
->first(); ->first();
?> ?>
@@ -182,19 +183,19 @@
</td> </td>
<td class="pe-0"> <td class="pe-0">
@if(isset($max)) @if(isset($max))
@if($max->segmentasi == 'Penggerak') @if($max->segmen == 'Penggerak')
<span class="text-success">Petani Penggerak</span> <span class="text-success">Petani Penggerak</span>
@elseif($max->segmentasi == 'Perintis') @elseif($max->segmen == 'Perintis')
<span class="text-info">Petani Perintis</span> <span class="text-info">Petani Perintis</span>
@elseif($max->segmentasi == 'Pemerhati') @elseif($max->segmen == 'Pemerhati')
<span class="text-warning">Petani Pemerhati</span> <span class="text-warning">Petani Pemerhati</span>
@elseif($max->segmentasi == 'Pemula') @elseif($max->segmen == 'Pemula')
<span class="text-danger">Petani Pemula</span> <span class="text-danger">Petani Pemula</span>
@else @else
<span>Belum Lengkap</span> <span>Belum Lengkap</span>
@endif @endif
@else @else
<span>Belum Ada</span> <span>Belum Tersegmentasi</span>
@endif @endif
</td> </td>
<td class="text-end pe-0"> <td class="text-end pe-0">