@extends('layouts.user_type.auth') @section('content')
@php $perPageOptions = [10, 25, 50, 100]; // Define CSV files and their identifiers (from public/storage folder) $datasets = [ 'dana' => [ 'path' => public_path('storage/data_labeled.csv'), 'title' => 'Dana', 'anchor' => 'dana', ], 'gopay' => [ 'path' => public_path('storage/data_labeledgopay.csv'), 'title' => 'GoPay', 'anchor' => 'gopay', ], 'shopee' => [ 'path' => public_path('storage/data_labeledshopee.csv'), 'title' => 'ShopeePay', 'anchor' => 'shopeepay', ], ]; // Which columns to display $displayCols = ['clean_text', 'label_auto']; // Build paginators and headers foreach ($datasets as $key => $info) { $allRows = file_exists($info['path']) ? array_map('str_getcsv', file($info['path'])) : []; ${"header_{$key}"} = count($allRows) > 1 ? array_shift($allRows) : []; // Determine display column indices ${"displayIdxs_{$key}"} = []; foreach (${"header_{$key}"} as $i => $col) { if (in_array($col, $displayCols)) { ${"displayIdxs_{$key}"}[] = $i; } } $perPageKey = 'per_page_' . $key; $pageKey = 'page_' . $key; ${"perPage_{$key}"} = (int) request()->get($perPageKey, 10); ${"currentPage_{$key}"} = (int) request()->get($pageKey, 1); ${"paginator_{$key}"} = new \Illuminate\Pagination\LengthAwarePaginator( array_slice($allRows, (${"currentPage_{$key}"} - 1) * ${"perPage_{$key}"}, ${"perPage_{$key}"}), count($allRows), ${"perPage_{$key}"}, ${"currentPage_{$key}"}, [ 'path' => url()->current(), 'pageName' => $pageKey, 'query' => request()->except($pageKey), ], ); } @endphp @foreach ($datasets as $key => $info) @php $header = ${"header_{$key}"}; $idxs = ${"displayIdxs_{$key}"}; $paginator = ${"paginator_{$key}"}; $perPage = ${"perPage_{$key}"}; $anchor = $info['anchor']; $title = $info['title']; @endphp
Data Sentimen {{ $title }} ({{ basename($info['path']) }})
@if (count($idxs)) @foreach ($idxs as $i) @endforeach @foreach ($paginator as $row) @foreach ($idxs as $i) @endforeach @endforeach
{{ $header[$i] }}
{{ $row[$i] }}
@else

Kolom untuk clean_text dan label_auto tidak ditemukan.

@endif
@if (count($idxs))
@foreach (request()->except(['per_page_' . $key, 'page_' . $key]) as $k => $v) @endforeach
{{ $paginator->firstItem() }}–{{ $paginator->lastItem() }} of {{ $paginator->total() }}
@endif
@endforeach
@endsection