From 1f653dda6c43d22e8a5b6327961423053e327bd6 Mon Sep 17 00:00:00 2001 From: MufridaFaraDiani27 Date: Wed, 22 Apr 2026 01:05:34 +0700 Subject: [PATCH] update fitur --- app/Http/Controllers/DashboardController.php | 36 +- .../Controllers/RekomendasiController.php | 25 +- app/Providers/AppServiceProvider.php | 2 + resources/views/analisis/index.blade.php | 335 ++++++++++++------ resources/views/dashboard.blade.php | 98 +++++ resources/views/layouts/sentara.blade.php | 10 +- resources/views/rekomendasi/index.blade.php | 285 +++++++++++---- 7 files changed, 586 insertions(+), 205 deletions(-) diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php index 2483567..5cc719d 100644 --- a/app/Http/Controllers/DashboardController.php +++ b/app/Http/Controllers/DashboardController.php @@ -10,7 +10,9 @@ class DashboardController extends Controller public function index(Request $request) { $wisata = $request->wisata; - + $evaluasi = DB::table('evaluasi_model') + ->latest() + ->first(); // ============================= // TOTAL ULASAN (DARI TABEL ULASAN) // ============================= @@ -115,14 +117,28 @@ public function index(Request $request) ->latest('created_at') ->value('created_at'); - return view('dashboard', compact( - 'stats', - 'chartSentimen', - 'chartDestinasi', - 'totalPerWisata', - 'allText', - 'lastUpdate', - 'hasAnalisis' - )); + $destinasiList = DB::table('ulasan') + ->select('wisata') + ->distinct() + ->pluck('wisata'); + +$hasil = DB::table('hasil_analisis') + ->when($wisata && $wisata != 'Semua Destinasi', function ($q) use ($wisata) { + $q->where('wisata', $wisata); + }) + ->paginate(10); + + return view('dashboard', compact( + 'stats', + 'chartSentimen', + 'chartDestinasi', + 'totalPerWisata', + 'allText', + 'lastUpdate', + 'hasAnalisis', + 'destinasiList', // WAJIB + 'hasil', + 'evaluasi' // WAJIB +)); } } \ No newline at end of file diff --git a/app/Http/Controllers/RekomendasiController.php b/app/Http/Controllers/RekomendasiController.php index 377b78d..07c5893 100644 --- a/app/Http/Controllers/RekomendasiController.php +++ b/app/Http/Controllers/RekomendasiController.php @@ -4,6 +4,7 @@ use Illuminate\Http\Request; use App\Models\HasilAnalisis; +use Illuminate\Support\Facades\DB; class RekomendasiController extends Controller { @@ -49,11 +50,23 @@ public function index(Request $request) // saran otomatis sederhana $saran = "Perlu peningkatan layanan terkait: " . $isuUtama; - return view('rekomendasi.index', compact( - 'destinasiList', - 'isuUtama', - 'kataDominan', - 'saran' - )); + $destinasiList = DB::table('hasil_analisis') + ->select('wisata') + ->distinct() + ->pluck('wisata'); + + + return view('dashboard', compact( + 'stats', + 'chartSentimen', + 'chartDestinasi', + 'totalPerWisata', + 'allText', + 'lastUpdate', + 'hasAnalisis', + 'wisataList', + 'hasil', + 'destinasiList' // ✅ TAMBAH INI +)); } } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 452e6b6..2fbdff0 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -3,6 +3,7 @@ namespace App\Providers; use Illuminate\Support\ServiceProvider; +use Illuminate\Pagination\Paginator; class AppServiceProvider extends ServiceProvider { @@ -19,6 +20,7 @@ public function register(): void */ public function boot(): void { + Paginator::useTailwind(); // } } diff --git a/resources/views/analisis/index.blade.php b/resources/views/analisis/index.blade.php index e13f342..829a195 100644 --- a/resources/views/analisis/index.blade.php +++ b/resources/views/analisis/index.blade.php @@ -1,146 +1,259 @@ -@extends('layouts.sentara') +
-@section('content') - -
- - + {{-- ================= HEADER ================= --}}
-

- Hasil Analisis Sentimen -

- - -
- -
+
+

Hasil Analisis Sentimen

+

+ Berikut adalah hasil evaluasi model dan detail analisis sentimen terhadap ulasan wisata. +

+
+
+ {{-- ================= METRICS ================= --}} +
- -
+
+

Precision

+

+ {{ $evaluasi->precision ?? 0 }} +

+
-

- Data Hasil Analisis -

+
+

Recall

+

+ {{ $evaluasi->recall ?? 0 }} +

+
-
- - - - - - - +
+

F1 Score

+

+ {{ $evaluasi->f1_score ?? 0 }} +

+
+ +
+

Akurasi

+

+ {{ $evaluasi->accuracy ?? 0 }} +

+
+ + + + {{-- ================= MATRIX + PERFORMA ================= --}} +
+ + {{-- CONFUSION MATRIX --}} +
+

Confusion Matrix

+ +
wisataUlasan TerolahSentimenProbabilitas
+ + + + + + - - @forelse($hasil as $row) - - - - - - - - - - - - - - - - @empty - - - - @endforelse + + + + + + + + + + + + + + + + + + -
PositifNegatifNetral
- {{ $row->wisata }} - - {{ $row->ulasan_terolah }} - - @if($row->sentimen == 'positif') - - Positif - - @elseif($row->sentimen == 'negatif') - - Negatif - - @else - - Netral - - @endif - - {{ number_format($row->probabilitas, 2) }} -
- Belum ada hasil analisis sentimen. -
Positif{{ $evaluasi->tp ?? 0 }}{{ $evaluasi->fn ?? 0 }}0
Negatif{{ $evaluasi->fp ?? 0 }}{{ $evaluasi->tn ?? 0 }}0
Netral000
- -
- Showing {{ $hasil->firstItem() }} to {{ $hasil->lastItem() }} - of {{ $hasil->total() }} results -
+ {{-- PERFORMA --}} +
+

Performa per Kelas

-
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KelasPrecisionRecallF1Support
Positif{{ $evaluasi->precision ?? 0 }}{{ $evaluasi->recall ?? 0 }}{{ $evaluasi->f1_score ?? 0 }}-
Negatif{{ $evaluasi->precision ?? 0 }}{{ $evaluasi->recall ?? 0 }}{{ $evaluasi->f1_score ?? 0 }}-
Netral{{ $evaluasi->precision ?? 0 }}{{ $evaluasi->recall ?? 0 }}{{ $evaluasi->f1_score ?? 0 }}-
+
+ +
+ + {{-- ================= FILTER ================= --}} +
+ + + + + + + +
+ + {{-- ================= TABLE ================= --}} +
+ +

Detail Hasil Analisis Sentimen

+ + + + + + + + + + + + + + @forelse($hasil as $index => $item) + + + + + + + + + + @empty + + + + @endforelse + +
NoWisataUlasanSentimenProbabilitas
{{ $loop->iteration }}{{ $item->wisata }}{{ Str::limit($item->ulasan_terolah, 80) }} + + {{ $item->sentimen }} + + {{ $item->probabilitas ?? '-' }}
+ Tidak ada data +
+ + {{-- PAGINATION --}} +
+ + {{-- INFO --}} +
+ Menampilkan {{ $hasil->firstItem() }} - {{ $hasil->lastItem() }} + dari {{ $hasil->total() }} data +
+ + {{-- PAGINATION --}} + {{-- PAGINATION --}} +
{{-- PREV --}} @if ($hasil->onFirstPage()) - + @else - + @endif - @php - $start = max($hasil->currentPage() - 2, 1); - $end = min($hasil->currentPage() + 2, $hasil->lastPage()); - @endphp + {{-- PAGE NUMBERS --}} + @foreach ($hasil->getUrlRange(1, $hasil->lastPage()) as $page => $url) - {{-- NUMBER --}} - @for ($i = $start; $i <= $end; $i++) - @if ($i == $hasil->currentPage()) - - {{ $i }} + @php + $query = request()->query(); + $query['page'] = $page; + $customUrl = url()->current() . '?' . http_build_query($query); + @endphp + + @if ($page == $hasil->currentPage()) + + {{ $page }} - @else - - {{ $i }} + + @elseif ($page <= 3 || $page > $hasil->lastPage()-3 || abs($page - $hasil->currentPage()) <= 1) + + + {{ $page }} + + @elseif ($page == 4 || $page == $hasil->lastPage()-3) + ... @endif - @endfor + + @endforeach {{-- NEXT --}} @if ($hasil->hasMorePages()) - + @else - + @endif +
+
-
- -@endsection +
\ No newline at end of file diff --git a/resources/views/dashboard.blade.php b/resources/views/dashboard.blade.php index c0b7857..0344742 100644 --- a/resources/views/dashboard.blade.php +++ b/resources/views/dashboard.blade.php @@ -11,6 +11,38 @@
@endif +
+ + +
+ + + + + + + +
+ +
{{-- Statistik Cards --}}
@@ -94,10 +126,22 @@
+
+ +
+ @include('analisis.index')
+ +
+ @include('rekomendasi.index') +
+ +
+ + {{-- ========================= --}} {{-- SCRIPT SECTION --}} {{-- ========================= --}} @@ -173,4 +217,58 @@ }); + + + @endsection \ No newline at end of file diff --git a/resources/views/layouts/sentara.blade.php b/resources/views/layouts/sentara.blade.php index 339b0c0..3d25482 100644 --- a/resources/views/layouts/sentara.blade.php +++ b/resources/views/layouts/sentara.blade.php @@ -26,23 +26,23 @@ diff --git a/resources/views/rekomendasi/index.blade.php b/resources/views/rekomendasi/index.blade.php index 0e93d72..e7ca28c 100644 --- a/resources/views/rekomendasi/index.blade.php +++ b/resources/views/rekomendasi/index.blade.php @@ -1,89 +1,228 @@ -@extends('layouts.sentara') +
-@section('content') - -
- - + {{-- HEADER --}}
-

- Rekomendasi Layanan -

- - -
- + -
-
- -
- - -
-

- Isu Utama -

- -
- - Kebersihan - - - Parkir - +
- -
-

- Kata Kunci Dominan -

+ {{-- SUMMARY --}} +
+ +
+
😟
+
+

Total Ulasan Negatif

+

312

+

25,06% dari total

+
+
+ +
+
😊
+
+

Tingkat Kepuasan

+

68%

+ + Sedang + +
+
+ +
+
+
+

Isu Dominan

+

Kebersihan

+

45% dari total isu

+
+
+ + -
    -
  • - kotor - 15x -
  • -
  • - parkir - 10x -
  • -
  • - mahal - 7x -
  • -
- -
-

- Saran Perbaikan -

+ {{-- GRID ANALISIS --}} +
+ + {{-- ISU UTAMA --}} +
+

Isu Utama (Top 5)

+ + @php + $isu = [ + ['nama'=>'Kebersihan','persen'=>45,'warna'=>'red'], + ['nama'=>'Parkir','persen'=>30,'warna'=>'orange'], + ['nama'=>'Harga / Tiket','persen'=>15,'warna'=>'yellow'], + ['nama'=>'Fasilitas','persen'=>6,'warna'=>'green'], + ['nama'=>'Keramaian','persen'=>4,'warna'=>'blue'], + ]; + @endphp + + @foreach($isu as $i => $item) +
+
+ {{ $i+1 }}. {{ $item['nama'] }} + {{ $item['persen'] }}% +
+
+
+
+
+
+ @endforeach + +
+ + {{-- KEYWORD --}} +
+

Kata Kunci Dominan

+ + @php + $keywords = [ + ['kotor',15], + ['parkir',10], + ['mahal',7], + ['sampah',6], + ['toilet',5], + ]; + @endphp + + @foreach($keywords as $k) +
+
+ {{ $k[0] }} + {{ $k[1] }}x +
+
+
+
+
+ @endforeach + +
+ + {{-- SARAN --}} +
+

Saran Perbaikan

+ +
+ +
+
🧹
+
+

Perbaikan Kebersihan

+

+ Tambah tempat sampah & jadwal pembersihan rutin. +

+
+
+ +
+
🚗
+
+

Penataan Parkir

+

+ Sistem parkir lebih rapi dan transparan. +

+
+
+ +
+
🏷️
+
+

Evaluasi Harga

+

+ Penyesuaian harga tiket agar lebih terjangkau. +

+
+
+ +
+
-

- Perlu peningkatan kebersihan area wisata serta evaluasi sistem - pengelolaan parkir untuk meningkatkan kenyamanan pengunjung. -

-
+ {{-- PRIORITAS --}} +
-
+ {{-- CARD 1 --}} +
+

Prioritas 1

+

Kebersihan

-@endsection +
    +
  • ✔ Tambah tempat sampah
  • +
  • ✔ Jadwal pembersihan rutin
  • +
  • ✔ Petugas kebersihan tambahan
  • +
+ +
+ Dampak: Kepuasan meningkat signifikan +
+
+ + {{-- CARD 2 --}} +
+

Prioritas 2

+

Parkir

+ +
    +
  • ✔ Penataan area parkir
  • +
  • ✔ Tarif transparan
  • +
  • ✔ Petugas lebih ramah
  • +
+ +
+ Dampak: Mengurangi keluhan +
+
+ + {{-- CARD 3 --}} +
+

Prioritas 3

+

Harga

+ +
    +
  • ✔ Evaluasi harga tiket
  • +
  • ✔ Promo wisata
  • +
  • ✔ Diskon tertentu
  • +
+ +
+ Dampak: Daya tarik meningkat +
+
+ +
+ +
\ No newline at end of file