mohan #14
@ -109,6 +109,10 @@ private function formatWorker(Worker $w)
|
|||||||
'updated_at' => $doc->updated_at?->toISOString(),
|
'updated_at' => $doc->updated_at?->toISOString(),
|
||||||
];
|
];
|
||||||
})->toArray(),
|
})->toArray(),
|
||||||
|
'category' => [
|
||||||
|
'id' => 7,
|
||||||
|
'name' => 'General Helper',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -396,11 +400,11 @@ public function getCandidates(Request $request)
|
|||||||
// Fetch Job Applications
|
// Fetch Job Applications
|
||||||
$jobIds = JobPost::where('employer_id', $employerId)->pluck('id');
|
$jobIds = JobPost::where('employer_id', $employerId)->pluck('id');
|
||||||
$applicationsQuery = JobApplication::whereIn('job_id', $jobIds)
|
$applicationsQuery = JobApplication::whereIn('job_id', $jobIds)
|
||||||
->with(['worker', 'jobPost']);
|
->with(['worker.skills', 'worker.documents', 'jobPost']);
|
||||||
|
|
||||||
// Fetch Direct Hiring Offers
|
// Fetch Direct Hiring Offers
|
||||||
$directOffersQuery = JobOffer::where('employer_id', $employerId)
|
$directOffersQuery = JobOffer::where('employer_id', $employerId)
|
||||||
->with('worker');
|
->with('worker.skills', 'worker.documents');
|
||||||
|
|
||||||
// Apply search filter if provided
|
// Apply search filter if provided
|
||||||
if ($request->filled('search')) {
|
if ($request->filled('search')) {
|
||||||
@ -430,39 +434,15 @@ public function getCandidates(Request $request)
|
|||||||
elseif ($app->status === 'applied') $status = 'Reviewing';
|
elseif ($app->status === 'applied') $status = 'Reviewing';
|
||||||
else $status = ucfirst($app->status);
|
else $status = ucfirst($app->status);
|
||||||
|
|
||||||
$langs = ($w->id % 2 === 0) ? ['English', 'Arabic'] : (($w->id % 3 === 0) ? ['English', 'Tagalog'] : ['English', 'Hindi', 'Arabic']);
|
$formattedWorker = $this->formatWorker($w);
|
||||||
$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];
|
|
||||||
|
|
||||||
return [
|
return array_merge($formattedWorker, [
|
||||||
'id' => $app->id,
|
'id' => $app->id,
|
||||||
'worker_id' => $w->id,
|
'worker_id' => $w->id,
|
||||||
'name' => $w->name,
|
|
||||||
'nationality' => $w->nationality,
|
|
||||||
'status' => $status,
|
'status' => $status,
|
||||||
'applied_at' => $app->created_at->format('Y-m-d H:i:s'),
|
'applied_at' => $app->created_at->format('Y-m-d H:i:s'),
|
||||||
'type' => 'application',
|
'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();
|
})->filter()->values()->toArray();
|
||||||
|
|
||||||
// Fetch Direct Hiring Offers
|
// Fetch Direct Hiring Offers
|
||||||
@ -477,39 +457,15 @@ public function getCandidates(Request $request)
|
|||||||
elseif ($offer->status === 'rejected') $status = 'Rejected';
|
elseif ($offer->status === 'rejected') $status = 'Rejected';
|
||||||
elseif ($offer->status === 'pending') $status = 'Offer Sent';
|
elseif ($offer->status === 'pending') $status = 'Offer Sent';
|
||||||
|
|
||||||
$langs = ($w->id % 2 === 0) ? ['English', 'Arabic'] : (($w->id % 3 === 0) ? ['English', 'Tagalog'] : ['English', 'Hindi', 'Arabic']);
|
$formattedWorker = $this->formatWorker($w);
|
||||||
$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];
|
|
||||||
|
|
||||||
return [
|
return array_merge($formattedWorker, [
|
||||||
'id' => 'offer_' . $offer->id,
|
'id' => 'offer_' . $offer->id,
|
||||||
'worker_id' => $w->id,
|
'worker_id' => $w->id,
|
||||||
'name' => $w->name,
|
|
||||||
'nationality' => $w->nationality,
|
|
||||||
'status' => $status,
|
'status' => $status,
|
||||||
'applied_at' => $offer->created_at->format('Y-m-d H:i:s'),
|
'applied_at' => $offer->created_at->format('Y-m-d H:i:s'),
|
||||||
'type' => 'direct_offer',
|
'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();
|
})->filter()->values()->toArray();
|
||||||
|
|
||||||
// Merge and sort
|
// Merge and sort
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user