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
+11 -2
View File
@@ -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'));