phase 8
This commit is contained in:
@@ -8,6 +8,9 @@ use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class JobSearchService
|
||||
{
|
||||
public function __construct(
|
||||
private CacheService $cacheService
|
||||
) {}
|
||||
/**
|
||||
* Search jobs with advanced filters
|
||||
*/
|
||||
@@ -188,36 +191,40 @@ class JobSearchService
|
||||
*/
|
||||
public function getFilterOptions(): array
|
||||
{
|
||||
return [
|
||||
'job_types' => [
|
||||
'full-time' => 'Full-time',
|
||||
'part-time' => 'Part-time',
|
||||
'contract' => 'Contract',
|
||||
'temporary' => 'Temporary',
|
||||
'internship' => 'Internship',
|
||||
'freelance' => 'Freelance',
|
||||
],
|
||||
'experience_levels' => [
|
||||
'entry' => 'Entry Level',
|
||||
'mid' => 'Mid Level',
|
||||
'senior' => 'Senior Level',
|
||||
'lead' => 'Lead',
|
||||
'executive' => 'Executive',
|
||||
],
|
||||
'posted_within' => [
|
||||
1 => 'Last 24 hours',
|
||||
7 => 'Last 7 days',
|
||||
30 => 'Last 30 days',
|
||||
90 => 'Last 3 months',
|
||||
],
|
||||
'sort_options' => [
|
||||
'date' => 'Most Recent',
|
||||
'date_asc' => 'Oldest First',
|
||||
'salary_desc' => 'Highest Salary',
|
||||
'salary_asc' => 'Lowest Salary',
|
||||
'title' => 'Title A-Z',
|
||||
'company' => 'Company A-Z',
|
||||
],
|
||||
];
|
||||
$cacheKey = $this->cacheService->filterOptionsKey();
|
||||
|
||||
return $this->cacheService->remember($cacheKey, CacheService::CACHE_FILTER_OPTIONS, function () {
|
||||
// Get actual distinct values from database for job types and experience levels
|
||||
$jobTypes = Job::select('job_type')
|
||||
->whereNotNull('job_type')
|
||||
->distinct()
|
||||
->pluck('job_type')
|
||||
->toArray();
|
||||
|
||||
$experienceLevels = Job::select('experience_level')
|
||||
->whereNotNull('experience_level')
|
||||
->distinct()
|
||||
->pluck('experience_level')
|
||||
->toArray();
|
||||
|
||||
return [
|
||||
'job_types' => $jobTypes,
|
||||
'experience_levels' => $experienceLevels,
|
||||
'posted_within' => [
|
||||
1 => 'Last 24 hours',
|
||||
7 => 'Last 7 days',
|
||||
30 => 'Last 30 days',
|
||||
90 => 'Last 3 months',
|
||||
],
|
||||
'sort_options' => [
|
||||
'date' => 'Most Recent',
|
||||
'date_asc' => 'Oldest First',
|
||||
'salary_desc' => 'Highest Salary',
|
||||
'salary_asc' => 'Lowest Salary',
|
||||
'title' => 'Title A-Z',
|
||||
'company' => 'Company A-Z',
|
||||
],
|
||||
];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user