Fix: updated AdminController with pagination
This commit is contained in:
parent
55637c44a9
commit
3b5962ee5b
@ -1,5 +1,5 @@
|
||||
APP_NAME=lupmisBackend
|
||||
APP_ENV=production
|
||||
APP_ENV=local
|
||||
APP_KEY=base64:pmEAeuW8clKrfKKjcMWylo68exoDO/Xr2hUhXvB7dS0=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost:9031
|
||||
|
||||
@ -28,17 +28,33 @@ class AdminController extends Controller
|
||||
|
||||
|
||||
// 2. Define pagination parameters
|
||||
$perPage = 10;
|
||||
$perPage = 15;
|
||||
$search = request()->input('search');
|
||||
if ($search) {
|
||||
$filteredData = collect($users_arr['data'])->filter(function ($item) use ($search) {
|
||||
// Adjust fields to search in (e.g., 'title', 'category')
|
||||
return str_contains(strtolower($item['full_name']), strtolower($search)) ||
|
||||
str_contains(strtolower($item['email']), strtolower($search)) ||
|
||||
str_contains(strtolower($item['username']), strtolower($search)) ||
|
||||
str_contains(strtolower($item['phone']), strtolower($search)) ||
|
||||
str_contains(strtolower($item['allowed_apps']), strtolower($search)) ||
|
||||
str_contains(strtolower($item['ua_position']), strtolower($search)) ||
|
||||
str_contains(strtolower($item['phone']), strtolower($search));
|
||||
})->values()->all(); // Reset array keys
|
||||
} else {
|
||||
$filteredData = $users_arr['data'];
|
||||
}
|
||||
|
||||
$currentPage = LengthAwarePaginator::resolveCurrentPage() ?: 1;
|
||||
$offset = ($currentPage - 1) * $perPage;
|
||||
|
||||
// 3. Slice the array to get the items for the current page
|
||||
$currentPageItems = array_slice($users_arr['data'], $offset, $perPage);
|
||||
$currentPageItems = array_slice($filteredData, $offset, $perPage);
|
||||
|
||||
// 4. Create the LengthAwarePaginator instance
|
||||
$paginatedItems = new LengthAwarePaginator(
|
||||
$currentPageItems, // Items for the current page
|
||||
count($users_arr['data']), // Total number of items
|
||||
count($filteredData), // Total number of items
|
||||
$perPage, // Items per page
|
||||
$currentPage, // Current page number
|
||||
['path' => request()->url(), 'query' => request()->query()] // Options to preserve query strings and path
|
||||
|
||||
@ -10,3 +10,13 @@ chmod -R 0777 bootstrap/
|
||||
|
||||
|
||||
sudo chmod -R 777 /path/to/folder_name
|
||||
|
||||
use application instea
|
||||
add permit fee to initial email
|
||||
permit issued and signed
|
||||
application approved pending
|
||||
upload site inspection report
|
||||
add measurements to the backend for works department
|
||||
|
||||
|
||||
216.55.137.19
|
||||
@ -20,8 +20,29 @@
|
||||
<h3>Users</h3>
|
||||
<!-- <a href="" class="float-end">Add User</a> -->
|
||||
<div class="float-end pb-2" >
|
||||
<!-- <form action="{{ url('admin/search') }}" method="GET">
|
||||
<input type="text" name="search" placeholder="Search items..." value="{{ request('search') }}">
|
||||
<button type="submit">Search</button>
|
||||
</form> -->
|
||||
|
||||
<button type="button" class="btn btn-warning btn-sm" data-bs-toggle="modal" data-bs-target="#addUserModal">
|
||||
Add User</button>
|
||||
<i class="bi bi-plus-circle"></i> Add User</button>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<!-- Search form on the left -->
|
||||
<div class="col-md-4">
|
||||
<form action="{{ url('admin/home') }}" method="GET">
|
||||
<div class="input-group">
|
||||
<input type="text" name="search" class="form-control" placeholder="Search..." value="{{ request('search') }}">
|
||||
<button class="btn btn-primary btn-sm" type="submit">
|
||||
<i class="bi bi-search"></i>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<table class="table table-hover table-bordered table-condensed">
|
||||
<thead class="">
|
||||
@ -60,10 +81,16 @@
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
{{ $items->links() }}
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="float-end pb-2" >
|
||||
Showing {{ $items->currentPage() }} of {{ $items->lastPage() }} pages | {{ $items->total() }} records
|
||||
</div>
|
||||
<div class="d-flex justify-content-centerw">
|
||||
{{ $items->links() }}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
|
||||
<!-- Styles -->
|
||||
<link rel="stylesheet" href="{{ url('public/assets/libs/bootstrap/css/bootstrap5.3.2.css') }}">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.13.1/font/bootstrap-icons.min.css">
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
@ -21,6 +21,8 @@
|
||||
<link rel="stylesheet" href="{{ url('public/assets/css/l4l.css') }}" rel="stylesheet">
|
||||
<link rel="stylesheet" href="{{ url('public/assets/css/styles.css') }}" rel="stylesheet">
|
||||
<link rel="stylesheet" href="{{ url('public/assets/libs/fontawesome-free-7.1.0-web/css/all.min.css') }}" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.13.1/font/bootstrap-icons.min.css">
|
||||
|
||||
@yield('page-css')
|
||||
<script type="text/javascript">
|
||||
var base_url = "{!! url('/') !!}";
|
||||
|
||||
@ -39,6 +39,7 @@ Route::middleware([CheckBackendSession::class])->group(function () {
|
||||
Route::get('/landing', [App\Http\Controllers\LandingpageController::class, 'index']);
|
||||
|
||||
Route::get('/admin/home', [App\Http\Controllers\AdminController::class, 'index']);
|
||||
Route::get('/admin/search', [App\Http\Controllers\AdminController::class, 'index']);
|
||||
Route::get('/admin/districtparams', [App\Http\Controllers\AdminController::class, 'districtparams']);
|
||||
Route::get('/admin/luspaparams', [App\Http\Controllers\AdminController::class, 'luspaparams']);
|
||||
Route::get('/admin/reports', [App\Http\Controllers\AdminController::class, 'reports']);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user