This commit is contained in:
aarsyah0 2025-05-31 23:26:35 +07:00
parent edf4f3893d
commit 3084846b2a
1 changed files with 46 additions and 20 deletions

View File

@ -340,41 +340,66 @@
<div class="row mt-5"> <div class="row mt-5">
@foreach (['dana', 'gopay', 'shopeepay'] as $key) @foreach (['dana', 'gopay', 'shopeepay'] as $key)
@php @php
// Path ke CSV: storage/app/public/top_features_{key}.csv // Path ke CSV (perhatikan key: 'shopeepay' kalau memang file bernama top_features_shopeepay.csv)
$featuresPath = storage_path("app/public/top_features_{$key}.csv"); $featuresPath = storage_path("app/public/top_features_{$key}.csv");
$featuresData = []; $featuresRaw = [];
if (file_exists($featuresPath)) { if (file_exists($featuresPath)) {
$featuresData = array_map('str_getcsv', file($featuresPath)); // Baca CSV (masingmasing baris jadi array)
$featuresRaw = array_map('str_getcsv', file($featuresPath));
}
// Siapkan array untuk menampung fitur per kelas
$classFeatures = [
'neutral' => [], // nanti kita label sebagai “Netral”
'positive' => [], // nanti jadi “Positif”
'negative' => [], // nanti jadi “Negatif”
];
if (count($featuresRaw) > 1) {
// Baris pertama adalah header: [rank,neutral,positive,negative]
// Mulai loop dari index ke-1 (data sebenarnya)
foreach (array_slice($featuresRaw, 1) as $row) {
// $row[1] = neutral, $row[2] = positive, $row[3] = negative
$classFeatures['neutral'][] = $row[1] ?? '';
$classFeatures['positive'][] = $row[2] ?? '';
$classFeatures['negative'][] = $row[3] ?? '';
}
} }
@endphp @endphp
<div class="col-lg-4 col-md-6 mb-4"> <div class="col-lg-4 col-md-6 mb-4">
<div class="card bg-white border-radius-lg shadow-lg h-100"> <div class="card bg-white border-radius-lg shadow-lg h-100">
{{-- Header Kartu dengan Gradient Soft UI --}} {{-- Header Kartu --}}
<div class="card-header bg-gradient-secondary border-radius-lg-top text-center py-2"> <div class="card-header bg-gradient-secondary border-radius-lg-top text-center py-2">
<h6 class="mb-0 text-uppercase text-white font-weight-bold"> <h6 class="mb-0 text-uppercase text-white font-weight-bold">
{{ $key }} Top Features {{ ucfirst($key) }} Top Features
</h6> </h6>
</div> </div>
{{-- Body Kartu --}} {{-- Body Kartu --}}
<div class="card-body p-0"> <div class="card-body p-3">
@if (count($featuresData) > 1) @if (count($featuresRaw) > 1)
<ul class="list-group list-group-flush"> <div class="row">
@foreach (array_slice($featuresData, 1) as $row) {{-- Tiga kolom kecil: Netral, Positif, Negatif --}}
{{-- Kolom pertama = nama fitur, kolom kedua = skor --}} @foreach ([
<li 'neutral' => 'Netral',
class="list-group-item d-flex justify-content-between align-items-center px-3 py-2"> 'positive' => 'Positif',
<span class="font-weight-medium text-dark"> 'negative' => 'Negatif',
{{ $row[0] }} ] as $clsKey => $clsLabel)
</span> <div class="col-4">
<span class="badge badge-sm bg-gradient-secondary"> <h6 class="text-secondary text-uppercase text-center">{{ $clsLabel }}</h6>
{{ $row[1] }} <ul class="list-group list-group-flush">
</span> @foreach ($classFeatures[$clsKey] as $feature)
</li> <li class="list-group-item px-2 py-1 small">
{{ $feature }}
</li>
@endforeach
</ul>
</div>
@endforeach @endforeach
</ul> </div>
@else @else
{{-- Jika file tidak ada atau kosong --}}
<div class="alert alert-warning text-center mb-0 py-3 small rounded-bottom-lg"> <div class="alert alert-warning text-center mb-0 py-3 small rounded-bottom-lg">
File <code>top_features_{{ $key }}.csv</code> tidak ditemukan atau kosong. File <code>top_features_{{ $key }}.csv</code> tidak ditemukan atau kosong.
</div> </div>
@ -385,6 +410,7 @@
@endforeach @endforeach
</div> </div>
{{-- ======================================================================== --}} {{-- ======================================================================== --}}
@endsection @endsection