improvements for the jobs page
This commit is contained in:
@@ -7,8 +7,10 @@ use App\Models\AnalyticsEvent;
|
||||
use App\Models\Job;
|
||||
use App\Models\JobCategory;
|
||||
use App\Repositories\JobRepository;
|
||||
use App\Services\CacheService;
|
||||
use App\Services\JobSearchService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class JobController extends Controller
|
||||
{
|
||||
@@ -17,6 +19,13 @@ class JobController extends Controller
|
||||
private JobRepository $jobRepository
|
||||
) {}
|
||||
|
||||
private function getCategoriesWithCount()
|
||||
{
|
||||
return Cache::remember('categories:with_job_count', CacheService::CACHE_CATEGORIES, function () {
|
||||
return JobCategory::withCount('jobs')->orderBy('name')->get();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of jobs with search and filters
|
||||
*/
|
||||
@@ -44,7 +53,7 @@ class JobController extends Controller
|
||||
$perPage = $request->input('per_page', 20);
|
||||
$jobs = $this->searchService->search($filters, $perPage);
|
||||
|
||||
$categories = JobCategory::withCount('jobs')->orderBy('name')->get();
|
||||
$categories = $this->getCategoriesWithCount();
|
||||
$filterOptions = $this->searchService->getFilterOptions();
|
||||
|
||||
return view('jobs.index', compact('jobs', 'categories', 'filterOptions', 'filters'));
|
||||
@@ -117,7 +126,7 @@ class JobController extends Controller
|
||||
$perPage = $request->input('per_page', 20);
|
||||
$jobs = $this->searchService->search($filters, $perPage);
|
||||
|
||||
$categories = JobCategory::withCount('jobs')->orderBy('name')->get();
|
||||
$categories = $this->getCategoriesWithCount();
|
||||
$filterOptions = $this->searchService->getFilterOptions();
|
||||
|
||||
return view('jobs.remote', compact('jobs', 'categories', 'filterOptions', 'filters'));
|
||||
|
||||
Reference in New Issue
Block a user