mohan #5
@ -76,6 +76,7 @@ private function formatWorker(Worker $w)
|
|||||||
'rating' => $rating,
|
'rating' => $rating,
|
||||||
'reviews_count' => $reviewsCount,
|
'reviews_count' => $reviewsCount,
|
||||||
'preferred_location' => $w->preferred_location,
|
'preferred_location' => $w->preferred_location,
|
||||||
|
'area' => $w->area,
|
||||||
'live_in_out' => $w->live_in_out,
|
'live_in_out' => $w->live_in_out,
|
||||||
'in_country' => (bool)$w->in_country,
|
'in_country' => (bool)$w->in_country,
|
||||||
];
|
];
|
||||||
@ -199,6 +200,25 @@ public function getWorkers(Request $request)
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Filter: area
|
||||||
|
if ($request->filled('area')) {
|
||||||
|
$areaParam = $request->area;
|
||||||
|
$areasArray = is_array($areaParam) ? $areaParam : array_filter(array_map('trim', explode(',', $areaParam)));
|
||||||
|
$areasArray = array_map('strtolower', $areasArray);
|
||||||
|
|
||||||
|
$workersArray = array_values(array_filter($workersArray, function ($c) use ($areasArray) {
|
||||||
|
if (!isset($c['area'])) return false;
|
||||||
|
$wArea = strtolower($c['area']);
|
||||||
|
foreach ($areasArray as $a) {
|
||||||
|
if ($a === 'all') return true;
|
||||||
|
if (str_contains($wArea, $a)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
// Filter: job_type / preferred_job_type
|
// Filter: job_type / preferred_job_type
|
||||||
$jobTypeParam = $request->input('job_type') ?? $request->input('preferred_job_type');
|
$jobTypeParam = $request->input('job_type') ?? $request->input('preferred_job_type');
|
||||||
if ($jobTypeParam) {
|
if ($jobTypeParam) {
|
||||||
@ -388,6 +408,7 @@ public function getCandidates(Request $request)
|
|||||||
'languages' => $langs,
|
'languages' => $langs,
|
||||||
'availability' => $w->availability ?? 'Immediate',
|
'availability' => $w->availability ?? 'Immediate',
|
||||||
'preferred_location' => $w->preferred_location,
|
'preferred_location' => $w->preferred_location,
|
||||||
|
'area' => $w->area,
|
||||||
'preferred_job_type' => $preferredJobType,
|
'preferred_job_type' => $preferredJobType,
|
||||||
'live_in_out' => $w->live_in_out,
|
'live_in_out' => $w->live_in_out,
|
||||||
'in_country' => (bool)$w->in_country,
|
'in_country' => (bool)$w->in_country,
|
||||||
@ -429,6 +450,7 @@ public function getCandidates(Request $request)
|
|||||||
'languages' => $langs,
|
'languages' => $langs,
|
||||||
'availability' => $w->availability ?? 'Immediate',
|
'availability' => $w->availability ?? 'Immediate',
|
||||||
'preferred_location' => $w->preferred_location,
|
'preferred_location' => $w->preferred_location,
|
||||||
|
'area' => $w->area,
|
||||||
'preferred_job_type' => $preferredJobType,
|
'preferred_job_type' => $preferredJobType,
|
||||||
'live_in_out' => $w->live_in_out,
|
'live_in_out' => $w->live_in_out,
|
||||||
'in_country' => (bool)$w->in_country,
|
'in_country' => (bool)$w->in_country,
|
||||||
@ -527,6 +549,25 @@ public function getCandidates(Request $request)
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Filter: area
|
||||||
|
if ($request->filled('area')) {
|
||||||
|
$areaParam = $request->area;
|
||||||
|
$areasArray = is_array($areaParam) ? $areaParam : array_filter(array_map('trim', explode(',', $areaParam)));
|
||||||
|
$areasArray = array_map('strtolower', $areasArray);
|
||||||
|
|
||||||
|
$mergedCandidates = array_values(array_filter($mergedCandidates, function ($c) use ($areasArray) {
|
||||||
|
if (!isset($c['area'])) return false;
|
||||||
|
$wArea = strtolower($c['area']);
|
||||||
|
foreach ($areasArray as $a) {
|
||||||
|
if ($a === 'all') return true;
|
||||||
|
if (str_contains($wArea, $a)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
// Filter: job_type / preferred_job_type
|
// Filter: job_type / preferred_job_type
|
||||||
$jobTypeParam = $request->input('job_type') ?? $request->input('preferred_job_type');
|
$jobTypeParam = $request->input('job_type') ?? $request->input('preferred_job_type');
|
||||||
if ($jobTypeParam) {
|
if ($jobTypeParam) {
|
||||||
|
|||||||
@ -27,14 +27,14 @@ public function register(Request $request)
|
|||||||
'mobile' => 'required|string|max:50|unique:sponsors,mobile',
|
'mobile' => 'required|string|max:50|unique:sponsors,mobile',
|
||||||
'password' => 'required|string|min:6',
|
'password' => 'required|string|min:6',
|
||||||
'license_file' => 'required|file|mimes:jpeg,png,jpg,pdf|max:10240',
|
'license_file' => 'required|file|mimes:jpeg,png,jpg,pdf|max:10240',
|
||||||
'emirates_id_file' => 'nullable|file|mimes:jpeg,png,jpg,pdf|max:10240',
|
'emirates_id_file' => 'required|file|mimes:jpeg,png,jpg,pdf|max:10240',
|
||||||
'organization_name' => 'nullable|string|max:255',
|
'organization_name' => 'required|string|max:255',
|
||||||
'email' => 'nullable|email|max:255|unique:sponsors,email',
|
'email' => 'required|email|max:255|unique:sponsors,email',
|
||||||
'nationality' => 'nullable|string|max:100',
|
'nationality' => 'required|string|max:100',
|
||||||
'city' => 'nullable|string|max:100',
|
'city' => 'required|string|max:100',
|
||||||
'address' => 'nullable|string|max:255',
|
'address' => 'required|string|max:255',
|
||||||
'country_code' => 'nullable|string|max:10',
|
'country_code' => 'required|string|max:10',
|
||||||
'license_expiry' => 'nullable|date_format:Y-m-d',
|
'license_expiry' => 'required|date_format:Y-m-d',
|
||||||
], [
|
], [
|
||||||
'mobile.unique' => 'This mobile number is already registered.',
|
'mobile.unique' => 'This mobile number is already registered.',
|
||||||
'email.unique' => 'This email address is already registered.',
|
'email.unique' => 'This email address is already registered.',
|
||||||
|
|||||||
@ -29,7 +29,20 @@
|
|||||||
"multipart/form-data": {
|
"multipart/form-data": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": ["full_name", "mobile", "password", "license_file"],
|
"required": [
|
||||||
|
"full_name",
|
||||||
|
"mobile",
|
||||||
|
"password",
|
||||||
|
"license_file",
|
||||||
|
"emirates_id_file",
|
||||||
|
"organization_name",
|
||||||
|
"email",
|
||||||
|
"nationality",
|
||||||
|
"city",
|
||||||
|
"address",
|
||||||
|
"country_code",
|
||||||
|
"license_expiry"
|
||||||
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"full_name": {
|
"full_name": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@ -55,38 +68,44 @@
|
|||||||
"emirates_id_file": {
|
"emirates_id_file": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"format": "binary",
|
"format": "binary",
|
||||||
"description": "Emirates ID document file (jpg/png/pdf, max 10MB). (OPTIONAL)"
|
"description": "Emirates ID document file (jpg/png/pdf, max 10MB). (REQUIRED)"
|
||||||
},
|
},
|
||||||
"organization_name": {
|
"organization_name": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "Al-Rashidi Charitable Foundation",
|
"example": "Al-Rashidi Charitable Foundation",
|
||||||
"description": "Name of the sponsoring organization."
|
"description": "Name of the sponsoring organization. (REQUIRED)"
|
||||||
},
|
},
|
||||||
"email": {
|
"email": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"format": "email",
|
"format": "email",
|
||||||
"example": "info@alrashidi.ae",
|
"example": "info@alrashidi.ae",
|
||||||
"description": "Email address (optional — auto-generated if not provided)."
|
"description": "Email address (must be unique). (REQUIRED)"
|
||||||
},
|
},
|
||||||
"nationality": {
|
"nationality": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "UAE",
|
"example": "UAE",
|
||||||
"description": "Nationality of the sponsor."
|
"description": "Nationality of the sponsor. (REQUIRED)"
|
||||||
},
|
},
|
||||||
"city": {
|
"city": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "Dubai",
|
"example": "Dubai",
|
||||||
"description": "City of residence."
|
"description": "City of residence. (REQUIRED)"
|
||||||
},
|
},
|
||||||
"address": {
|
"address": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "Villa 12, Jumeirah 2",
|
"example": "Villa 12, Jumeirah 2",
|
||||||
"description": "Physical address."
|
"description": "Physical address. (REQUIRED)"
|
||||||
},
|
},
|
||||||
"country_code": {
|
"country_code": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "+971",
|
"example": "+971",
|
||||||
"description": "Country dial code."
|
"description": "Country dial code. (REQUIRED)"
|
||||||
|
},
|
||||||
|
"license_expiry": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "date",
|
||||||
|
"example": "2028-06-12",
|
||||||
|
"description": "Expiry date of the license (YYYY-MM-DD). (REQUIRED)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3316,6 +3335,15 @@
|
|||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "area",
|
||||||
|
"in": "query",
|
||||||
|
"required": false,
|
||||||
|
"description": "Filter by preferred area (comma-separated list, e.g. Marina,Al Barsha).",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "job_type",
|
"name": "job_type",
|
||||||
"in": "query",
|
"in": "query",
|
||||||
@ -4520,6 +4548,14 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "+971509998888"
|
"example": "+971509998888"
|
||||||
},
|
},
|
||||||
|
"language": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "HI"
|
||||||
|
},
|
||||||
|
"fcm_token": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "fcm_token_example"
|
||||||
|
},
|
||||||
"nationality": {
|
"nationality": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "Egypt"
|
"example": "Egypt"
|
||||||
@ -4568,6 +4604,14 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "Tourist Visa"
|
"example": "Tourist Visa"
|
||||||
},
|
},
|
||||||
|
"passport_status": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "Passport Verified"
|
||||||
|
},
|
||||||
|
"emirates_id_status": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "Passport Verified"
|
||||||
|
},
|
||||||
"preferred_job_type": {
|
"preferred_job_type": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "full-time"
|
"example": "full-time"
|
||||||
|
|||||||
@ -51,6 +51,7 @@ protected function setUp(): void
|
|||||||
'verified' => true,
|
'verified' => true,
|
||||||
'status' => 'active',
|
'status' => 'active',
|
||||||
'preferred_location' => 'Dubai',
|
'preferred_location' => 'Dubai',
|
||||||
|
'area' => 'Al Barsha',
|
||||||
'preferred_job_type' => 'full-time',
|
'preferred_job_type' => 'full-time',
|
||||||
'live_in_out' => 'live_in',
|
'live_in_out' => 'live_in',
|
||||||
'in_country' => true,
|
'in_country' => true,
|
||||||
@ -82,6 +83,7 @@ protected function setUp(): void
|
|||||||
'verified' => true,
|
'verified' => true,
|
||||||
'status' => 'active',
|
'status' => 'active',
|
||||||
'preferred_location' => 'Abu Dhabi',
|
'preferred_location' => 'Abu Dhabi',
|
||||||
|
'area' => 'Khalifa City',
|
||||||
'preferred_job_type' => 'part-time',
|
'preferred_job_type' => 'part-time',
|
||||||
'live_in_out' => 'live_out',
|
'live_in_out' => 'live_out',
|
||||||
'in_country' => true,
|
'in_country' => true,
|
||||||
@ -113,6 +115,7 @@ protected function setUp(): void
|
|||||||
'verified' => true,
|
'verified' => true,
|
||||||
'status' => 'active',
|
'status' => 'active',
|
||||||
'preferred_location' => 'Dubai',
|
'preferred_location' => 'Dubai',
|
||||||
|
'area' => 'Marina',
|
||||||
'preferred_job_type' => 'full-time',
|
'preferred_job_type' => 'full-time',
|
||||||
'live_in_out' => 'live_out',
|
'live_in_out' => 'live_out',
|
||||||
'in_country' => false,
|
'in_country' => false,
|
||||||
@ -348,4 +351,52 @@ public function test_get_workers_gender_filter()
|
|||||||
$workers2 = $response2->json('data.workers');
|
$workers2 = $response2->json('data.workers');
|
||||||
$this->assertCount(2, $workers2);
|
$this->assertCount(2, $workers2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_get_workers_area_filter()
|
||||||
|
{
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'Authorization' => 'Bearer ' . $this->token,
|
||||||
|
])->getJson('/api/employers/workers?area=Marina');
|
||||||
|
|
||||||
|
$response->assertStatus(200);
|
||||||
|
$workers = $response->json('data.workers');
|
||||||
|
$this->assertCount(1, $workers);
|
||||||
|
$this->assertEquals('Worker Kenya Out Country', $workers[0]['name']);
|
||||||
|
$this->assertEquals('Marina', $workers[0]['area']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_get_candidates_area_filter()
|
||||||
|
{
|
||||||
|
$worker1 = Worker::where('nationality', 'India')->first();
|
||||||
|
$worker2 = Worker::where('nationality', 'Philippines')->first();
|
||||||
|
|
||||||
|
JobOffer::create([
|
||||||
|
'employer_id' => $this->employer->id,
|
||||||
|
'worker_id' => $worker1->id,
|
||||||
|
'work_date' => now()->format('Y-m-d'),
|
||||||
|
'location' => 'Dubai',
|
||||||
|
'salary' => 1500,
|
||||||
|
'notes' => 'Hired test',
|
||||||
|
'status' => 'accepted',
|
||||||
|
]);
|
||||||
|
|
||||||
|
JobOffer::create([
|
||||||
|
'employer_id' => $this->employer->id,
|
||||||
|
'worker_id' => $worker2->id,
|
||||||
|
'work_date' => now()->format('Y-m-d'),
|
||||||
|
'location' => 'Abu Dhabi',
|
||||||
|
'salary' => 1500,
|
||||||
|
'notes' => 'Hired test 2',
|
||||||
|
'status' => 'accepted',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'Authorization' => 'Bearer ' . $this->token,
|
||||||
|
])->getJson('/api/employers/candidates?area=Al Barsha');
|
||||||
|
|
||||||
|
$response->assertStatus(200);
|
||||||
|
$candidates = $response->json('data.candidates');
|
||||||
|
$this->assertCount(1, $candidates);
|
||||||
|
$this->assertEquals('Worker India In Dubai', $candidates[0]['name']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,8 +29,11 @@ public function test_sponsor_can_register_with_license()
|
|||||||
'license_file' => $licenseFile,
|
'license_file' => $licenseFile,
|
||||||
'emirates_id_file' => $emiratesIdFile,
|
'emirates_id_file' => $emiratesIdFile,
|
||||||
'organization_name' => 'Charity Co',
|
'organization_name' => 'Charity Co',
|
||||||
|
'email' => 'test.sponsor@example.com',
|
||||||
'nationality' => 'Emirati',
|
'nationality' => 'Emirati',
|
||||||
'city' => 'Abu Dhabi',
|
'city' => 'Abu Dhabi',
|
||||||
|
'address' => 'Villa 45, Street 12',
|
||||||
|
'country_code' => '+971',
|
||||||
'license_expiry' => '2028-06-12',
|
'license_expiry' => '2028-06-12',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user