diff --git a/php_code/.env b/php_code/.env index c58697d0..5195f955 100644 --- a/php_code/.env +++ b/php_code/.env @@ -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 diff --git a/php_code/app/Http/Controllers/AdminController.php b/php_code/app/Http/Controllers/AdminController.php index 2d535a17..043b3a0a 100644 --- a/php_code/app/Http/Controllers/AdminController.php +++ b/php_code/app/Http/Controllers/AdminController.php @@ -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 diff --git a/php_code/info.md b/php_code/info.md index a9268c7c..d1778ac2 100644 --- a/php_code/info.md +++ b/php_code/info.md @@ -9,4 +9,14 @@ chmod -R 0777 bootstrap/