diff --git a/app/Http/Controllers/Web/Dashboard/SummaryController.php b/app/Http/Controllers/Web/Dashboard/SummaryController.php index 77c4982..1ae24d6 100644 --- a/app/Http/Controllers/Web/Dashboard/SummaryController.php +++ b/app/Http/Controllers/Web/Dashboard/SummaryController.php @@ -4,8 +4,13 @@ namespace App\Http\Controllers\Web\Dashboard; use App\Http\Controllers\Controller; use Illuminate\Http\Request; +use App\Models\Profile; +use App\Models\Wilayah\Provinsi; +use App\Models\wilayah\KabupatenKota; +use App\Models\Wilayah\Kecamatan; +use App\Models\Wilayah\DesaKelurahan; +use App\Models\Pertanian\Lahan; use Illuminate\Support\Facades\Gate; - class SummaryController extends Controller { public function index() @@ -16,4 +21,128 @@ class SummaryController extends Controller $title = 'Summary Dashboard'; return view('dashboard.summary', compact('title')); } + + public function produktivitasBackup(Request $request) + { + if (!Gate::allows('super_admin') && !Gate::allows('admin')) { + abort(403); + } + $title = 'Produktivitas Dashboard'; + $luasTotal = Lahan::whereNotNull('path')->sum('luas_lahan'); + $totalpetani = Profile::where('role', 'petani')->count(); + $totallahan = Lahan::whereNotNull('path')->count(); + + $petaniList = Profile::where('role', 'petani') + ->with(['lahan.tanaman.komoditas', 'desaKelurahan']) + ->paginate(20); + + $allLahan = Lahan::whereNotNull('path') + ->with(['profile', 'tanaman.komoditas', 'desaKelurahan.kecamatan.kabupatenKota.provinsi']) + ->get() + ->map(function($lahan) { + return [ + 'id' => $lahan->id, + 'polygon' => $lahan->path, + 'nama_petani' => $lahan->profile->nama ?? 'N/A', + 'luas' => $lahan->luas_lahan, + 'tanaman' => $lahan->tanaman->map(fn($t) => $t->komoditas->nama ?? null)->filter()->unique()->values() + ]; + }); + + return view('dashboard.produktivitas', compact('title', 'petaniList', 'allLahan', 'totalpetani', 'totallahan', 'luasTotal')); + } + + public function produktivitas(Request $request) + { + if (!Gate::allows('super_admin') && !Gate::allows('admin')) { + abort(403); + } + + $title = 'Produktivitas Dashboard'; + $luasTotal = Lahan::whereNotNull('path')->sum('luas_lahan'); + $totalpetani = Profile::where('role', 'petani')->count(); + $totallahan = Lahan::whereNotNull('path')->count(); + + $petaniList = Profile::where('role', 'petani') + ->with(['lahan.tanaman.komoditas', 'desaKelurahan']) + ->paginate(20); + + $allLahan = Lahan::whereNotNull('path') + ->with(['profile', 'tanaman.komoditas', 'desaKelurahan.kecamatan.kabupatenKota.provinsi']) + ->get(); + + // Penampung data per level (menggunakan ID sebagai key agar unique) + $geoProvinsi = []; + $geoKabupaten = []; + $geoKecamatan = []; + $geoDesa = []; + $geoLahan = []; + + foreach ($allLahan as $lahan) { + $desa = $lahan->desaKelurahan; + $kec = $desa ? $desa->kecamatan : null; + $kab = $kec ? $kec->kabupatenKota : null; + $prov = $kab ? $kab->provinsi : null; + + // --- Akumulasi Provinsi --- + if ($prov && $prov->path) { + if (!isset($geoProvinsi[$prov->id])) { + $geoProvinsi[$prov->id] = ['id' => $prov->id, 'nama' => $prov->nama, 'polygon' => $prov->path, 'total_lahan' => 0, 'total_luas' => 0]; + } + $geoProvinsi[$prov->id]['total_lahan']++; + $geoProvinsi[$prov->id]['total_luas'] += $lahan->luas_lahan; + } + + // --- Akumulasi Kabupaten --- + if ($kab && $kab->path) { + if (!isset($geoKabupaten[$kab->id])) { + $geoKabupaten[$kab->id] = ['id' => $kab->id, 'parent_id' => $prov->id ?? null, 'nama' => $kab->nama, 'polygon' => $kab->path, 'total_lahan' => 0, 'total_luas' => 0]; + } + $geoKabupaten[$kab->id]['total_lahan']++; + $geoKabupaten[$kab->id]['total_luas'] += $lahan->luas_lahan; + } + + // --- Akumulasi Kecamatan --- + if ($kec && $kec->path) { + if (!isset($geoKecamatan[$kec->id])) { + $geoKecamatan[$kec->id] = ['id' => $kec->id, 'parent_id' => $kab->id ?? null, 'nama' => $kec->nama, 'polygon' => $kec->path, 'total_lahan' => 0, 'total_luas' => 0]; + } + $geoKecamatan[$kec->id]['total_lahan']++; + $geoKecamatan[$kec->id]['total_luas'] += $lahan->luas_lahan; + } + + // --- Akumulasi Desa --- + if ($desa && $desa->path) { + if (!isset($geoDesa[$desa->id])) { + $geoDesa[$desa->id] = ['id' => $desa->id, 'parent_id' => $kec->id ?? null, 'nama' => $desa->nama, 'polygon' => $desa->path, 'total_lahan' => 0, 'total_luas' => 0]; + } + $geoDesa[$desa->id]['total_lahan']++; + $geoDesa[$desa->id]['total_luas'] += $lahan->luas_lahan; + } + + // Data Lahan Tetap + $geoLahan[] = [ + 'id' => $lahan->id, + 'parent_id' => $desa->id ?? null, + 'polygon' => $lahan->path, + 'nama_petani' => $lahan->profile->nama ?? 'N/A', + 'luas' => $lahan->luas_lahan, + 'tanaman' => $lahan->tanaman->map(fn($t) => $t->komoditas->nama ?? null)->filter()->unique()->values() + ]; + } + + return view('dashboard.produktivitas', [ + 'title' => $title, + 'petaniList' => $petaniList, + 'totalpetani' => $totalpetani, + 'totallahan' => $totallahan, + 'luasTotal' => $luasTotal, + // Reset key array agar menjadi format list normal untuk JSON + 'geoProvinsi' => array_values($geoProvinsi), + 'geoKabupaten' => array_values($geoKabupaten), + 'geoKecamatan' => array_values($geoKecamatan), + 'geoDesa' => array_values($geoDesa), + 'geoLahan' => $geoLahan + ]); + } } diff --git a/app/Http/Controllers/Web/Konfigurasi/AuthController.php b/app/Http/Controllers/Web/Konfigurasi/AuthController.php index ec89fc6..63f2f12 100644 --- a/app/Http/Controllers/Web/Konfigurasi/AuthController.php +++ b/app/Http/Controllers/Web/Konfigurasi/AuthController.php @@ -15,13 +15,13 @@ class AuthController extends Controller public function login() { $title = 'Login'; - return view('auth.login', compact('title')); + return view('konfigurasi.auth.login', compact('title')); } public function register() { $title = 'Register'; - return view('auth.register', compact('title')); + return view('konfigurasi.auth.register', compact('title')); } public function createAccount(Request $request) @@ -42,7 +42,7 @@ class AuthController extends Controller 'deleted_by' => null, ]); - return redirect()->route('auth.login')->with('success', 'Account created successfully. Please login.'); + return redirect()->route('konfigurasi.auth.login')->with('success', 'Account created successfully. Please login.'); } public function verify(User $user) diff --git a/app/Http/Controllers/Web/Konfigurasi/ProfileController.php b/app/Http/Controllers/Web/Konfigurasi/ProfileController.php new file mode 100644 index 0000000..bc91d21 --- /dev/null +++ b/app/Http/Controllers/Web/Konfigurasi/ProfileController.php @@ -0,0 +1,21 @@ +user()->id; + $profile = Profile::where('user_id', $userid)->first(); + $title = 'Profile'; + return view('konfigurasi.profile.index', compact('title', 'profile')); + } +} diff --git a/app/Models/Pertanian/Lahan.php b/app/Models/Pertanian/Lahan.php index f4df020..7bfc525 100644 --- a/app/Models/Pertanian/Lahan.php +++ b/app/Models/Pertanian/Lahan.php @@ -37,22 +37,22 @@ class Lahan extends Model 'path' => 'array', ]; - public function profile(): BelongsTo + public function profile() { return $this->belongsTo(Profile::class, 'profile_id'); } - public function desaKelurahan(): BelongsTo + public function desaKelurahan() { return $this->belongsTo(DesaKelurahan::class, 'desa_kelurahan_id'); } - public function adat(): BelongsTo + public function adat() { return $this->belongsTo(Adat::class, 'adat_pemilik_id'); } - public function tanaman(): HasMany + public function tanaman() { return $this->hasMany(Tanaman::class, 'lahan_id'); } diff --git a/app/Models/Pertanian/Tanaman.php b/app/Models/Pertanian/Tanaman.php index 8106923..3ce7eea 100644 --- a/app/Models/Pertanian/Tanaman.php +++ b/app/Models/Pertanian/Tanaman.php @@ -7,6 +7,9 @@ use Illuminate\Database\Eloquent\SoftDeletes; use App\Models\Pertanian\Komoditas; use App\Models\Pertanian\Lahan; use App\Models\Profile; +use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Database\Eloquent\Relations\BelongsTo; + class Tanaman extends Model { diff --git a/app/Models/Profile.php b/app/Models/Profile.php index f91d3b5..e961336 100644 --- a/app/Models/Profile.php +++ b/app/Models/Profile.php @@ -4,9 +4,11 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; - use App\Models\User; +use App\Models\Pertanian\Lahan; use App\Models\Wilayah\DesaKelurahan; +use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Database\Eloquent\Relations\BelongsTo; class Profile extends Model { @@ -42,4 +44,9 @@ class Profile extends Model { return $this->belongsTo(User::class, 'user_id'); } + + public function lahan(): HasMany + { + return $this->hasMany(Lahan::class, 'profile_id'); + } } diff --git a/app/Models/Wilayah/DesaKelurahan.php b/app/Models/Wilayah/DesaKelurahan.php index 2885f9f..b0c5239 100644 --- a/app/Models/Wilayah/DesaKelurahan.php +++ b/app/Models/Wilayah/DesaKelurahan.php @@ -5,6 +5,9 @@ namespace App\Models\wilayah; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; use App\Models\Wilayah\Kecamatan; +use App\Models\Pertanian\Lahan; +use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\HasMany; class DesaKelurahan extends Model { @@ -21,4 +24,9 @@ class DesaKelurahan extends Model public function kecamatan() { return $this->belongsTo(Kecamatan::class, 'kecamatan_id'); } + + public function lahan() + { + return $this->hasMany(Lahan::class, 'desa_kelurahan_id'); + } } diff --git a/app/Models/Wilayah/KabupatenKota.php b/app/Models/Wilayah/KabupatenKota.php index 4a45103..bba4885 100644 --- a/app/Models/Wilayah/KabupatenKota.php +++ b/app/Models/Wilayah/KabupatenKota.php @@ -6,6 +6,8 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; use App\Models\Wilayah\Provinsi; use App\Models\Wilayah\Kecamatan; +use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\HasMany; class KabupatenKota extends Model { diff --git a/app/Models/Wilayah/Kecamatan.php b/app/Models/Wilayah/Kecamatan.php index 2e287a2..2ef5bcb 100644 --- a/app/Models/Wilayah/Kecamatan.php +++ b/app/Models/Wilayah/Kecamatan.php @@ -6,6 +6,8 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; use App\Models\Wilayah\KabupatenKota; use App\Models\Wilayah\DesaKelurahan; +use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\HasMany; class Kecamatan extends Model { diff --git a/app/Models/Wilayah/Provinsi.php b/app/Models/Wilayah/Provinsi.php index 81c65bc..8dba547 100644 --- a/app/Models/Wilayah/Provinsi.php +++ b/app/Models/Wilayah/Provinsi.php @@ -5,6 +5,8 @@ namespace App\Models\Wilayah; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; use App\Models\Wilayah\KabupatenKota; +use App\Models\Wilayah\DesaKelurahan; +use Illuminate\Database\Eloquent\Relations\HasMany; class Provinsi extends Model { diff --git a/public/assets/img/pages/profile-banner.png b/public/assets/img/pages/profile-banner.png new file mode 100644 index 0000000..bdb9ba7 Binary files /dev/null and b/public/assets/img/pages/profile-banner.png differ diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php index 4eda5f9..b88a647 100644 --- a/resources/views/auth/login.blade.php +++ b/resources/views/auth/login.blade.php @@ -4,7 +4,7 @@
- +
+
+ + + +

Selamat datang di AgroMonev!

+

Silakan masuk ke akun Anda

+ @if ($errors->any()) +
+
    + @foreach ($errors->all() as $error) +
  • {{ $error }}
  • + @endforeach +
+
+ @endif +
+ @csrf +
+ + +
+
+ +
+ + +
+
+
+
+
+ + +
+ +

Lupa Password?

+
+
+
+
+ +
+
+ +

+ Anda belum terdaftar? + + Buat akun baru + +

+ + + +
+
+@endsection \ No newline at end of file diff --git a/resources/views/konfigurasi/profile/index.blade.php b/resources/views/konfigurasi/profile/index.blade.php new file mode 100644 index 0000000..988529f --- /dev/null +++ b/resources/views/konfigurasi/profile/index.blade.php @@ -0,0 +1,558 @@ +@extends('layout.main') + +@section('content') +
+ +
+
+
+ + +
+
+
+ + + +
+
+ +
+
+ + + +
+
+ +
+
+

Tentang Pengguna

+
    +
  • + Nama Lengkap: {{ $profile->nama ?? 'N/A' }} +
  • +
  • + Role: + {{ $profile->role ?? 'N/A' }} +
  • +
  • + Wilayah: + {{ $profile->desa_kelurahan_id ?? 'N/A' }} +
  • +
  • + No KTP: + {{ $profile->ktp ?? 'N/A' }} +
  • +
  • + No KK: + {{ $profile->kk ?? 'N/A' }} +
  • +
+

Kontak

+
    +
  • + Telepon: + {{ $profile->telepon ?? 'N/A' }} +
  • +
  • + Email: + {{ $profile->email ?? 'N/A' }} +
  • +
+

Teams

+
    +
  • + Backend Developer(126 Members) +
  • +
  • + React Developer(98 Members) +
  • +
+
+
+ + +
+
+

Overview

+
    +
  • + Komoditas: 13.5k +
  • +
  • + Jumlah Lahan: 146 +
  • +
  • + Total Luas Lahan: 897 +
  • +
+
+
+ +
+
+ +
+
+
+ Activity Timeline +
+
+ +
+
+
+
    +
  • + +
    +
    +
    12 Invoices have been paid
    + 12 min ago +
    +

    Invoices have been paid to the company

    +
    +
    + img + invoices.pdf +
    +
    +
    +
  • +
  • + +
    +
    +
    Client Meeting
    + 45 min ago +
    +

    Project meeting with john @10:15am

    +
    +
    +
    + Avatar +
    +
    +

    Lester McCarthy (Client)

    + CEO of Pixinvent +
    +
    +
    +
    +
  • +
  • + +
    +
    +
    Create a new project for client
    + 2 Day Ago +
    +

    6 team members in a project

    +
      +
    • +
      +
        +
      • + Avatar +
      • +
      • + Avatar +
      • +
      • + Avatar +
      • +
      • + +3 +
      • +
      +
      +
    • +
    +
    +
  • +
+
+
+ +
+ +
+
+
+
Connections
+
+ +
+
+
+
    +
  • +
    +
    +
    + Avatar +
    +
    +
    Cecilia Payne
    + 45 Connections +
    +
    +
    + +
    +
    +
  • +
  • +
    +
    +
    + Avatar +
    +
    +
    Curtis Fletcher
    + 1.32k Connections +
    +
    +
    + +
    +
    +
  • +
  • +
    +
    +
    + Avatar +
    +
    +
    Alice Stone
    + 125 Connections +
    +
    +
    + +
    +
    +
  • +
  • +
    +
    +
    + Avatar +
    +
    +
    Darrell Barnes
    + 456 Connections +
    +
    +
    + +
    +
    +
  • + +
  • +
    +
    +
    + Avatar +
    +
    +
    Eugenia Moore
    + 1.2k Connections +
    +
    +
    + +
    +
    +
  • +
  • + View all connections +
  • +
+
+
+
+ + +
+
+
+
Teams
+
+ +
+
+
+
    +
  • +
    +
    +
    + Avatar +
    +
    +
    React Developers
    + 72 Members +
    +
    +
    + Developer +
    +
    +
  • +
  • +
    +
    +
    + Avatar +
    +
    +
    Support Team
    + 122 Members +
    +
    +
    + Support +
    +
    +
  • +
  • +
    +
    +
    + Avatar +
    +
    +
    UI Designers
    + 7 Members +
    +
    +
    + Designer +
    +
    +
  • +
  • +
    +
    +
    + Avatar +
    +
    +
    Vue.js Developers
    + 289 Members +
    +
    +
    + Developer +
    +
    +
  • +
  • +
    +
    +
    + Avatar +
    +
    +
    Digital Marketing
    + 24 Members +
    +
    +
    + Marketing +
    +
    +
  • +
  • + View all teams +
  • +
+
+
+
+ +
+ + + +
+
+ +
+@endsection \ No newline at end of file diff --git a/resources/views/layout/navbar.blade.php b/resources/views/layout/navbar.blade.php index 629f8b6..2285155 100644 --- a/resources/views/layout/navbar.blade.php +++ b/resources/views/layout/navbar.blade.php @@ -361,7 +361,7 @@
  • - + Profil Saya diff --git a/resources/views/layout/sidebar.blade.php b/resources/views/layout/sidebar.blade.php index 8069570..823c5f9 100644 --- a/resources/views/layout/sidebar.blade.php +++ b/resources/views/layout/sidebar.blade.php @@ -1,6 +1,6 @@
  • - - - @endsection @push('scripts') + + - @endsection @push('scripts') + +