header dan index
This commit is contained in:
@@ -15,6 +15,9 @@ use App\Models\Wilayah\Provinsi;
|
||||
use App\Models\Pertanian\Petani;
|
||||
use App\Models\Wilayah\DesaKelurahan;
|
||||
use App\Models\Pertanian\Komoditas;
|
||||
use App\Models\Pertanian\Tanaman;
|
||||
use App\Models\Pertanian\Lahan;
|
||||
use App\Models\Pertanian\SkorPetani;
|
||||
|
||||
use App\Enums\Pendidikan;
|
||||
use App\Enums\Pekerjaan;
|
||||
@@ -49,7 +52,29 @@ class PetaniController extends Controller
|
||||
|
||||
$petani = $query->paginate($request->per_page ?? 10);
|
||||
|
||||
return view('produktivitas.petani.index', compact('petani', 'provinsi'));
|
||||
$komoditas = Komoditas::where('is_utama', true)->get();
|
||||
$lahan = Lahan::whereIn('petani_id', $petani->pluck('id'))
|
||||
->whereIn('komoditas_id', $komoditas->pluck('id'))
|
||||
->get();
|
||||
$tanaman = Tanaman::whereIn('lahan_id', $lahan->pluck('id'))
|
||||
->whereIn('lahan_id', $lahan->pluck('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
|
||||
";
|
||||
$skor = SkorPetani::selectRaw("$case AS segmen, COUNT(*) AS total")
|
||||
->whereIn('petani_id', $petani->pluck('id'))
|
||||
->groupByRaw($case)
|
||||
->get();
|
||||
|
||||
return view('produktivitas.petani.index', compact('petani', 'provinsi', 'lahan', 'komoditas', 'tanaman', 'skor'));
|
||||
}
|
||||
|
||||
public function create()
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('master_komoditas', function (Blueprint $table) {
|
||||
$table->boolean('is_utama')->default(false);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('master_komoditas', function (Blueprint $table) {
|
||||
$table->dropColumn('is_utama');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -4,7 +4,7 @@
|
||||
<div class="card-body d-flex justify-content-between align-items-center">
|
||||
<div>
|
||||
<p class="text-muted fw-medium mb-1">{{ $title }}</p>
|
||||
<h3 class="text-dark fw-bold mb-1">{{ $count }}</h3>
|
||||
<h3 class="text-dark fw-bold mb-1">{!! $count !!}</h3>
|
||||
<small class="text-muted">{{ $subtitle }}</small>
|
||||
</div>
|
||||
<div class="badge bg-label-{{ $color }} p-2 rounded">
|
||||
|
||||
@@ -127,7 +127,7 @@
|
||||
</div>
|
||||
<span class="avatar">
|
||||
<span class="avatar-initial rounded">
|
||||
<i class="icon-base ti tabler-seedling icon-22px"></i>
|
||||
<i class="icon-base ti tabler-books icon-22px"></i>
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
@@ -175,13 +175,13 @@
|
||||
@if(!is_null($skorPraktik))
|
||||
<span class="me-1">{{ $praktik }}</span>
|
||||
@else
|
||||
<span class="me-1">Belum isi</span>
|
||||
<span class="me-1">Belum terisi</span>
|
||||
@endif
|
||||
</p>
|
||||
</div>
|
||||
<span class="avatar">
|
||||
<span class="avatar-initial rounded">
|
||||
<i class="icon-base ti tabler-books icon-22px"></i>
|
||||
<i class="icon-base ti tabler-seedling icon-22px"></i>
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
@@ -285,7 +285,7 @@
|
||||
@if(!is_null($aksesPasar?->skor_pengalaman) && !is_null($aksesPasar->skor_kesadaran_premium))
|
||||
<span class="me-1">{{ $pengalaman }}</span>
|
||||
@else
|
||||
<span class="me-1">Belum isi</span>
|
||||
<span class="me-1">Belum terisi</span>
|
||||
@endif
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -2,6 +2,36 @@
|
||||
|
||||
@section('content')
|
||||
<div class="container-xxl flex-grow-1 container-p-y">
|
||||
<div class="d-flex flex-row gap-3 mb-4">
|
||||
<div class="w-25">
|
||||
<x-summary-card
|
||||
title="Petani"
|
||||
count="{{ $petani->count() }}"
|
||||
subtitle="{{ $petani->where('jenis_kelamin', 1)->count() }} Laki-laki, {{ $petani->where('jenis_kelamin', 0)->count() }} Perempuan"
|
||||
icon="user-check"
|
||||
color="primary"
|
||||
/>
|
||||
</div>
|
||||
<div class="w-25">
|
||||
<x-summary-card
|
||||
title="Lahan & Tanaman"
|
||||
count="{{ number_format($lahan?->sum('luas_lahan'), 0, ',', '.') }}m<sup>2</sup>"
|
||||
subtitle="{{ $tanaman?->count() }} tanaman dari {{ $komoditas?->count() }} komoditas utama"
|
||||
icon="trees"
|
||||
color="success"
|
||||
/>
|
||||
</div>
|
||||
<div class="w-25">
|
||||
<x-summary-card
|
||||
title="Segmentasi"
|
||||
count="{{ $skor->where('segmen', 'Penggerak')->count() }} Penggerak"
|
||||
subtitle="{{ $skor->where('segmen', 'Perintis')->count() }} Perintis, {{ $skor->where('segmen', 'Pemerhati')->count() }} Pemerhati, {{ $skor->where('segmen', 'Pemula')->count() }} Pemula"
|
||||
icon="star"
|
||||
color="info"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header border-bottom">
|
||||
<h5 class="card-title mb-0">Data Petani</h5>
|
||||
@@ -40,6 +70,7 @@
|
||||
<th>Jenis Kelamin</th>
|
||||
<th>Usia</th>
|
||||
<th>Desa/Kelurahan</th>
|
||||
<th>Komoditas Utama</th>
|
||||
<th>Segmentasi</th>
|
||||
<th>Aksi</th>
|
||||
</tr>
|
||||
@@ -52,6 +83,7 @@
|
||||
<td><span class="text-muted">{{ $item->jenis_kelamin ? 'Laki-laki' : 'Perempuan' }}</span></td>
|
||||
<td><span class="text-muted">{{ $item->umur }} tahun</span></td>
|
||||
<td><span class="text-muted">{{ $item->desaKelurahan?->nama }}, {{ $item->desaKelurahan?->kecamatan?->nama }}, {{ $item->desaKelurahan?->kecamatan?->kabupatenKota?->nama }}, {{ $item->desaKelurahan?->kecamatan?->kabupatenKota?->provinsi?->nama }}</span></td>
|
||||
<td>{{ $item->komoditas?->nama }}</td>
|
||||
<td>
|
||||
@if($item->segmen() == 'Penggerak')
|
||||
<span class="badge bg-label-success">Penggerak</span>
|
||||
|
||||
Reference in New Issue
Block a user