improvements for the jobs page
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user