format candidates details to match workers API response structure exactly
This commit is contained in:
parent
8a8f6e86f8
commit
b2719888a2
@ -109,6 +109,10 @@ private function formatWorker(Worker $w)
|
||||
'updated_at' => $doc->updated_at?->toISOString(),
|
||||
];
|
||||
})->toArray(),
|
||||
'category' => [
|
||||
'id' => 7,
|
||||
'name' => 'General Helper',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@ -396,11 +400,11 @@ public function getCandidates(Request $request)
|
||||
// Fetch Job Applications
|
||||
$jobIds = JobPost::where('employer_id', $employerId)->pluck('id');
|
||||
$applicationsQuery = JobApplication::whereIn('job_id', $jobIds)
|
||||
->with(['worker', 'jobPost']);
|
||||
->with(['worker.skills', 'worker.documents', 'jobPost']);
|
||||
|
||||
// Fetch Direct Hiring Offers
|
||||
$directOffersQuery = JobOffer::where('employer_id', $employerId)
|
||||
->with('worker');
|
||||
->with('worker.skills', 'worker.documents');
|
||||
|
||||
// Apply search filter if provided
|
||||
if ($request->filled('search')) {
|
||||
@ -430,39 +434,15 @@ public function getCandidates(Request $request)
|
||||
elseif ($app->status === 'applied') $status = 'Reviewing';
|
||||
else $status = ucfirst($app->status);
|
||||
|
||||
$langs = ($w->id % 2 === 0) ? ['English', 'Arabic'] : (($w->id % 3 === 0) ? ['English', 'Tagalog'] : ['English', 'Hindi', 'Arabic']);
|
||||
$skillsList = ['cooking', 'driving', 'childcare', 'cleaning', 'elderly care', 'gardening'];
|
||||
$mappedSkills = [
|
||||
$skillsList[$w->id % 6],
|
||||
$skillsList[($w->id + 2) % 6]
|
||||
];
|
||||
$jobTypes = ['full-time', 'part-time', 'live-in', 'live-out'];
|
||||
$preferredJobType = $w->preferred_job_type ?? $jobTypes[$w->id % 4];
|
||||
$formattedWorker = $this->formatWorker($w);
|
||||
|
||||
return [
|
||||
return array_merge($formattedWorker, [
|
||||
'id' => $app->id,
|
||||
'worker_id' => $w->id,
|
||||
'name' => $w->name,
|
||||
'nationality' => $w->nationality,
|
||||
'status' => $status,
|
||||
'applied_at' => $app->created_at->format('Y-m-d H:i:s'),
|
||||
'type' => 'application',
|
||||
'skills' => $mappedSkills,
|
||||
'languages' => $langs,
|
||||
'availability' => $w->availability ?? 'Immediate',
|
||||
'preferred_location' => $w->preferred_location,
|
||||
'area' => $w->area,
|
||||
'preferred_job_type' => $preferredJobType,
|
||||
'live_in_out' => $w->live_in_out,
|
||||
'in_country' => (bool)$w->in_country,
|
||||
'visa_status' => $w->visa_status,
|
||||
'gender' => $w->gender,
|
||||
'age' => $w->age,
|
||||
'experience' => $w->experience,
|
||||
'visa_expiry_date' => $w->visa_expiry_date,
|
||||
'document_expiry_days' => $w->document_expiry_days,
|
||||
'document_expiry_status' => $w->document_expiry_status,
|
||||
];
|
||||
]);
|
||||
})->filter()->values()->toArray();
|
||||
|
||||
// Fetch Direct Hiring Offers
|
||||
@ -477,39 +457,15 @@ public function getCandidates(Request $request)
|
||||
elseif ($offer->status === 'rejected') $status = 'Rejected';
|
||||
elseif ($offer->status === 'pending') $status = 'Offer Sent';
|
||||
|
||||
$langs = ($w->id % 2 === 0) ? ['English', 'Arabic'] : (($w->id % 3 === 0) ? ['English', 'Tagalog'] : ['English', 'Hindi', 'Arabic']);
|
||||
$skillsList = ['cooking', 'driving', 'childcare', 'cleaning', 'elderly care', 'gardening'];
|
||||
$mappedSkills = [
|
||||
$skillsList[$w->id % 6],
|
||||
$skillsList[($w->id + 2) % 6]
|
||||
];
|
||||
$jobTypes = ['full-time', 'part-time', 'live-in', 'live-out'];
|
||||
$preferredJobType = $w->preferred_job_type ?? $jobTypes[$w->id % 4];
|
||||
$formattedWorker = $this->formatWorker($w);
|
||||
|
||||
return [
|
||||
return array_merge($formattedWorker, [
|
||||
'id' => 'offer_' . $offer->id,
|
||||
'worker_id' => $w->id,
|
||||
'name' => $w->name,
|
||||
'nationality' => $w->nationality,
|
||||
'status' => $status,
|
||||
'applied_at' => $offer->created_at->format('Y-m-d H:i:s'),
|
||||
'type' => 'direct_offer',
|
||||
'skills' => $mappedSkills,
|
||||
'languages' => $langs,
|
||||
'availability' => $w->availability ?? 'Immediate',
|
||||
'preferred_location' => $w->preferred_location,
|
||||
'area' => $w->area,
|
||||
'preferred_job_type' => $preferredJobType,
|
||||
'live_in_out' => $w->live_in_out,
|
||||
'in_country' => (bool)$w->in_country,
|
||||
'visa_status' => $w->visa_status,
|
||||
'gender' => $w->gender,
|
||||
'age' => $w->age,
|
||||
'experience' => $w->experience,
|
||||
'visa_expiry_date' => $w->visa_expiry_date,
|
||||
'document_expiry_days' => $w->document_expiry_days,
|
||||
'document_expiry_status' => $w->document_expiry_status,
|
||||
];
|
||||
]);
|
||||
})->filter()->values()->toArray();
|
||||
|
||||
// Merge and sort
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user