improvements for the jobs page

This commit is contained in:
Doar Mihai
2026-05-02 14:52:55 +03:00
parent 693d8013be
commit 1e5f394660
2 changed files with 24 additions and 10 deletions
+13 -8
View File
@@ -5,6 +5,7 @@ namespace App\Services;
use App\Models\Job;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\Request;
class JobSearchService
{
@@ -16,17 +17,21 @@ class JobSearchService
*/
public function search(array $filters = [], int $perPage = 15): LengthAwarePaginator
{
$query = Job::query()
->with(['source', 'category', 'jobLocation'])
->active();
$page = Request::input('page', 1);
$cacheKey = $this->cacheService->searchResultsKey($filters, (int) $page);
// Apply filters
$this->applyFilters($query, $filters);
$cached = $this->cacheService->remember($cacheKey, CacheService::CACHE_SEARCH_RESULTS, function () use ($filters, $perPage) {
$query = Job::query()
->with(['source', 'category', 'jobLocation'])
->active();
// Apply sorting
$this->applySorting($query, $filters['sort'] ?? 'date');
$this->applyFilters($query, $filters);
$this->applySorting($query, $filters['sort'] ?? 'date');
return $query->paginate($perPage);
return $query->paginate($perPage);
});
return $cached;
}
/**