From 13f0eb4d1681bc9fc2c67bc35938f5c422c50d8b Mon Sep 17 00:00:00 2001 From: aarsyah0 Date: Tue, 27 May 2025 15:04:23 +0700 Subject: [PATCH] done task --- .../laravel-examples/user-profile.blade.php | 527 +++++------------- routes/web.php | 27 +- 2 files changed, 163 insertions(+), 391 deletions(-) diff --git a/resources/views/laravel-examples/user-profile.blade.php b/resources/views/laravel-examples/user-profile.blade.php index 213d215..bef0fa6 100644 --- a/resources/views/laravel-examples/user-profile.blade.php +++ b/resources/views/laravel-examples/user-profile.blade.php @@ -1,4 +1,3 @@ -{{-- resources/views/sentimen/index.blade.php --}} @extends('layouts.user_type.auth') @section('content') @@ -6,403 +5,163 @@
@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 - {{-- === Table for Dana === --}} - @php - $pathDana = resource_path('views/danalabel.csv'); - $allRowsDana = file_exists($pathDana) ? array_map('str_getcsv', file($pathDana)) : []; - $headerDana = count($allRowsDana) > 1 ? array_shift($allRowsDana) : []; - $perPageDana = (int) request()->get('per_page_dana', 10); - $currentPageDana = (int) request()->get('page_dana', 1); - $paginatorDana = new \Illuminate\Pagination\LengthAwarePaginator( - array_slice($allRowsDana, ($currentPageDana - 1) * $perPageDana, $perPageDana), - count($allRowsDana), - $perPageDana, - $currentPageDana, - [ - 'path' => url()->current(), - 'pageName' => 'page_dana', - 'query' => request()->except('page_dana'), - ], - ); - @endphp -
-
-
-
Data Sentimen Dana (danalabel.csv)
-
-
-
- @if (count($headerDana)) - - - - @foreach ($headerDana as $col) - - @endforeach - - - - @foreach ($paginatorDana as $row) + @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)) +
- {{ $col }} -
+ - @foreach ($row as $cell) - + @foreach ($idxs as $i) + @endforeach - @endforeach - -
{{ $cell }} + {{ $header[$i] }}
- @else -

- File danalabel.csv tidak ditemukan atau kosong. -

- @endif -
- - @if (count($headerDana)) -
- {{-- Left: items per page + summary --}} -
- -
- - @foreach (request()->except(['per_page_dana', 'page_dana']) as $k => $v) - - @endforeach -
- - {{ $paginatorDana->firstItem() }}–{{ $paginatorDana->lastItem() }} of - {{ $paginatorDana->total() }} - -
- {{-- Right: pagination controls --}} - - + + + @else +

+ Kolom untuk clean_text dan label_auto tidak ditemukan. +

+ @endif
- @endif -
-
-
- - {{-- === Table for GoPay === --}} - @php - $pathGo = resource_path('views/gopaylabel.csv'); - $allRowsGo = file_exists($pathGo) ? array_map('str_getcsv', file($pathGo)) : []; - $headerGo = count($allRowsGo) > 1 ? array_shift($allRowsGo) : []; - $perPageGo = (int) request()->get('per_page_go', 10); - $currentPageGo = (int) request()->get('page_go', 1); - $paginatorGo = new \Illuminate\Pagination\LengthAwarePaginator( - array_slice($allRowsGo, ($currentPageGo - 1) * $perPageGo, $perPageGo), - count($allRowsGo), - $perPageGo, - $currentPageGo, - [ - 'path' => url()->current(), - 'pageName' => 'page_go', - 'query' => request()->except('page_go'), - ], - ); - @endphp -
-
-
-
Data Sentimen GoPay (gopaylabel.csv)
-
-
-
- @if (count($headerGo)) - - - - @foreach ($headerGo as $col) - - @endforeach - - - - @foreach ($paginatorGo as $row) - - @foreach ($row as $cell) - + @if (count($idxs)) +
+
+ +
+
- @endforeach - -
- {{ $col }} -
{{ $cell }}
- @else -

- File terlabelgopay.csv tidak ditemukan atau kosong. -

- @endif -
- - @if (count($headerGo)) -
-
- - - + @foreach (request()->except(['per_page_' . $key, 'page_' . $key]) as $k => $v) + @endforeach - - @foreach (request()->except(['per_page_go', 'page_go']) as $k => $v) - - @endforeach - - - {{ $paginatorGo->firstItem() }}–{{ $paginatorGo->lastItem() }} of - {{ $paginatorGo->total() }} - -
-
+ - -
- @endif +
  • + +
  • + @for ($i = max(1, $paginator->currentPage() - 2); $i <= min($paginator->lastPage(), $paginator->currentPage() + 2); $i++) +
  • + {{ $i }} +
  • + @endfor +
  • + +
  • +
  • + +
  • + + +
    + @endif +
    - - - {{-- === Table for ShopeePay === --}} - @php - $pathShopee = resource_path('views/shopeepaylabel.csv'); - $allRowsShopee = file_exists($pathShopee) ? array_map('str_getcsv', file($pathShopee)) : []; - $headerShopee = count($allRowsShopee) > 1 ? array_shift($allRowsShopee) : []; - $perPageShopee = (int) request()->get('per_page_shopee', 10); - $currentPageShopee = (int) request()->get('page_shopee', 1); - $paginatorShopee = new \Illuminate\Pagination\LengthAwarePaginator( - array_slice($allRowsShopee, ($currentPageShopee - 1) * $perPageShopee, $perPageShopee), - count($allRowsShopee), - $perPageShopee, - $currentPageShopee, - [ - 'path' => url()->current(), - 'pageName' => 'page_shopee', - 'query' => request()->except('page_shopee'), - ], - ); - @endphp -
    -
    -
    -
    Data Sentimen ShopeePay (shopepaylabel.csv)
    -
    -
    -
    - @if (count($headerShopee)) - - - - @foreach ($headerShopee as $col) - - @endforeach - - - - @foreach ($paginatorShopee as $row) - - @foreach ($row as $cell) - - @endforeach - - @endforeach - -
    - {{ $col }} -
    {{ $cell }}
    - @else -

    - File shopepaylabel.csv tidak ditemukan atau kosong. -

    - @endif -
    - - @if (count($headerShopee)) -
    -
    - -
    - - @foreach (request()->except(['per_page_shopee', 'page_shopee']) as $k => $v) - - @endforeach -
    - - {{ $paginatorShopee->firstItem() }}–{{ $paginatorShopee->lastItem() }} of - {{ $paginatorShopee->total() }} - -
    - - -
    - @endif - -
    -
    -
    + @endforeach diff --git a/routes/web.php b/routes/web.php index 2b4a40c..4c6338c 100644 --- a/routes/web.php +++ b/routes/web.php @@ -33,14 +33,27 @@ Route::group(['middleware' => 'auth'], function () { }); Route::group(['middleware' => 'guest'], function () { - Route::get('/register', [RegisterController::class, 'create']); - Route::post('/register', [RegisterController::class, 'store']); - Route::get('/login', [SessionsController::class, 'create']); - Route::post('/session', [SessionsController::class, 'store']); - Route::get('/login/forgot-password', [ResetController::class, 'create']); - Route::post('/forgot-password', [ResetController::class, 'sendEmail']); + // show login form + Route::get('/login', [SessionsController::class, 'create']) + ->name('login'); + + // process login + Route::post('/session', [SessionsController::class, 'store']) + ->name('session.store'); + + // registration + Route::get('/register', [RegisterController::class, 'create']) + ->name('register'); + Route::post('/register', [RegisterController::class, 'store']); + + // password reset + Route::get('/login/forgot-password', [ResetController::class, 'create']) + ->name('password.request'); + Route::post('/forgot-password', [ResetController::class, 'sendEmail']) + ->name('password.email'); Route::get('/reset-password/{token}', [ResetController::class, 'resetPass']) ->name('password.reset'); - Route::post('/reset-password', [ChangePasswordController::class, 'changePassword']) + Route::post('/reset-password', [ChangePasswordController::class, 'changePassword']) ->name('password.update'); }); +