api changes update
This commit is contained in:
parent
22f82b52a6
commit
9d8b35326d
@ -559,15 +559,6 @@ public function password(Request $request)
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$tokenToSend = $request->fcm_token ?? ($user ? $user->fcm_token : null) ?? ($sponsor ? $sponsor->fcm_token : null);
|
|
||||||
if ($tokenToSend) {
|
|
||||||
\App\Services\FCMService::sendPushNotification(
|
|
||||||
$tokenToSend,
|
|
||||||
'Welcome to Migrant',
|
|
||||||
'Your employer registration has been completed successfully.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'success' => true,
|
'success' => true,
|
||||||
'message' => 'Password created successfully. Registration finalized.',
|
'message' => 'Password created successfully. Registration finalized.',
|
||||||
|
|||||||
@ -28,8 +28,8 @@ public function getProfile(Request $request)
|
|||||||
if (!$profile) {
|
if (!$profile) {
|
||||||
$profile = EmployerProfile::create([
|
$profile = EmployerProfile::create([
|
||||||
'user_id' => $employer->id,
|
'user_id' => $employer->id,
|
||||||
'company_name' => 'Al Mansoor Household',
|
|
||||||
'phone' => '+971 50 123 4567',
|
'phone' => '+971 50 123 4567',
|
||||||
|
'address' => 'Dubai, UAE',
|
||||||
'verification_status' => 'approved',
|
'verification_status' => 'approved',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@ -37,9 +37,8 @@ public function getProfile(Request $request)
|
|||||||
$employerProfile = [
|
$employerProfile = [
|
||||||
'name' => $employer->name,
|
'name' => $employer->name,
|
||||||
'email' => $employer->email,
|
'email' => $employer->email,
|
||||||
'company_name' => $profile->company_name,
|
|
||||||
'phone' => $profile->phone,
|
'phone' => $profile->phone,
|
||||||
'language' => $profile->language ?? 'English',
|
'address' => $profile->address,
|
||||||
'notifications' => (bool)($profile->notifications ?? true),
|
'notifications' => (bool)($profile->notifications ?? true),
|
||||||
'verification_status' => $profile->verification_status ?? 'approved',
|
'verification_status' => $profile->verification_status ?? 'approved',
|
||||||
'emirates_id_number' => $profile->emirates_id_number,
|
'emirates_id_number' => $profile->emirates_id_number,
|
||||||
@ -94,8 +93,7 @@ public function updateProfile(Request $request)
|
|||||||
'unique:employer_profiles,phone,' . ($employer->employerProfile ? $employer->employerProfile->id : 'NULL'),
|
'unique:employer_profiles,phone,' . ($employer->employerProfile ? $employer->employerProfile->id : 'NULL'),
|
||||||
$sponsor ? 'unique:sponsors,mobile,' . $sponsor->id : 'unique:sponsors,mobile',
|
$sponsor ? 'unique:sponsors,mobile,' . $sponsor->id : 'unique:sponsors,mobile',
|
||||||
],
|
],
|
||||||
'company_name' => 'required|string|max:255',
|
'address' => 'required|string|max:255',
|
||||||
'language' => 'required|string|in:English,Arabic,english,arabic',
|
|
||||||
'notifications' => 'required|boolean',
|
'notifications' => 'required|boolean',
|
||||||
'current_password' => 'nullable|required_with:new_password|string',
|
'current_password' => 'nullable|required_with:new_password|string',
|
||||||
'new_password' => 'nullable|string|min:8|confirmed',
|
'new_password' => 'nullable|string|min:8|confirmed',
|
||||||
@ -144,6 +142,7 @@ public function updateProfile(Request $request)
|
|||||||
'full_name' => $request->name,
|
'full_name' => $request->name,
|
||||||
'email' => $request->email,
|
'email' => $request->email,
|
||||||
'mobile' => $request->phone,
|
'mobile' => $request->phone,
|
||||||
|
'address' => $request->address,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,9 +151,8 @@ public function updateProfile(Request $request)
|
|||||||
if (!$profile) {
|
if (!$profile) {
|
||||||
$profile = new EmployerProfile(['user_id' => $employer->id]);
|
$profile = new EmployerProfile(['user_id' => $employer->id]);
|
||||||
}
|
}
|
||||||
$profile->company_name = $request->company_name;
|
$profile->address = $request->address;
|
||||||
$profile->phone = $request->phone;
|
$profile->phone = $request->phone;
|
||||||
$profile->language = ucfirst(strtolower($request->language));
|
|
||||||
$profile->notifications = $request->notifications;
|
$profile->notifications = $request->notifications;
|
||||||
$profile->save();
|
$profile->save();
|
||||||
|
|
||||||
@ -168,9 +166,8 @@ public function updateProfile(Request $request)
|
|||||||
$employerProfile = [
|
$employerProfile = [
|
||||||
'name' => $employer->name,
|
'name' => $employer->name,
|
||||||
'email' => $employer->email,
|
'email' => $employer->email,
|
||||||
'company_name' => $profile->company_name,
|
|
||||||
'phone' => $profile->phone,
|
'phone' => $profile->phone,
|
||||||
'language' => $profile->language,
|
'address' => $profile->address,
|
||||||
'notifications' => (bool)$profile->notifications,
|
'notifications' => (bool)$profile->notifications,
|
||||||
'verification_status' => $profile->verification_status ?? 'approved',
|
'verification_status' => $profile->verification_status ?? 'approved',
|
||||||
'emirates_id_number' => $profile->emirates_id_number,
|
'emirates_id_number' => $profile->emirates_id_number,
|
||||||
|
|||||||
@ -22,23 +22,16 @@ class EmployerWorkerController extends Controller
|
|||||||
*/
|
*/
|
||||||
private function formatWorker(Worker $w)
|
private function formatWorker(Worker $w)
|
||||||
{
|
{
|
||||||
// Map languages with country names
|
// Map languages from database comma-separated string
|
||||||
$langs = ($w->id % 2 === 0) ? ['English', 'Arabic'] : (($w->id % 3 === 0) ? ['English', 'Tagalog'] : ['English', 'Hindi', 'Arabic']);
|
$langs = $w->language ? array_map('trim', explode(',', $w->language)) : ['English'];
|
||||||
|
|
||||||
// Preferred job types: full-time / part-time / live-in / live-out
|
// Preferred job types: full-time / part-time / live-in / live-out
|
||||||
$jobTypes = ['full-time', 'part-time', 'live-in', 'live-out'];
|
$jobTypes = ['full-time', 'part-time', 'live-in', 'live-out'];
|
||||||
$preferredJobType = $w->preferred_job_type ?? $jobTypes[$w->id % 4];
|
$preferredJobType = $w->preferred_job_type ?? $jobTypes[$w->id % 4];
|
||||||
|
|
||||||
// Emirates ID verification status (dynamic passport status)
|
// Emirates ID verification status
|
||||||
$emiratesIdStatus = $w->emirates_id_status;
|
$emiratesIdStatus = $w->emirates_id_status;
|
||||||
|
|
||||||
// Exact Skills mapping: cooking, driving, childcare, cleaning, elderly care, gardening
|
|
||||||
$skillsList = ['cooking', 'driving', 'childcare', 'cleaning', 'elderly care', 'gardening'];
|
|
||||||
$mappedSkills = [
|
|
||||||
$skillsList[$w->id % 6],
|
|
||||||
$skillsList[($w->id + 2) % 6]
|
|
||||||
];
|
|
||||||
|
|
||||||
// Visa status
|
// Visa status
|
||||||
$visaStatus = $w->visa_status;
|
$visaStatus = $w->visa_status;
|
||||||
|
|
||||||
@ -51,28 +44,64 @@ private function formatWorker(Worker $w)
|
|||||||
return [
|
return [
|
||||||
'id' => $w->id,
|
'id' => $w->id,
|
||||||
'name' => $w->name,
|
'name' => $w->name,
|
||||||
|
'phone' => $w->phone,
|
||||||
'nationality' => $w->nationality,
|
'nationality' => $w->nationality,
|
||||||
'photo' => $photo,
|
|
||||||
'emirates_id_status' => $emiratesIdStatus,
|
|
||||||
'passport_status' => $w->passport_status,
|
|
||||||
'skills' => $mappedSkills,
|
|
||||||
'visa_status' => $visaStatus,
|
|
||||||
'experience' => $w->experience,
|
|
||||||
'religion' => $w->religion,
|
|
||||||
'languages' => $langs,
|
|
||||||
'age' => $w->age,
|
'age' => $w->age,
|
||||||
'gender' => $w->gender,
|
'salary' => $w->salary,
|
||||||
|
'experience' => $w->experience,
|
||||||
'verified' => (bool)$w->verified,
|
'verified' => (bool)$w->verified,
|
||||||
'preferred_job_type' => $preferredJobType,
|
'status' => $w->status,
|
||||||
'bio' => $w->bio,
|
'created_at' => $w->created_at?->toISOString(),
|
||||||
'rating' => $rating,
|
'updated_at' => $w->updated_at?->toISOString(),
|
||||||
'reviews_count' => $reviewsCount,
|
'deleted_at' => $w->deleted_at?->toISOString(),
|
||||||
|
'language' => $w->language,
|
||||||
|
'languages' => $langs,
|
||||||
'preferred_location' => $w->preferred_location,
|
'preferred_location' => $w->preferred_location,
|
||||||
'area' => $w->area,
|
'area' => $w->area,
|
||||||
'live_in_out' => $w->live_in_out,
|
'live_in_out' => $w->live_in_out,
|
||||||
|
'gender' => $w->gender,
|
||||||
'in_country' => (bool)$w->in_country,
|
'in_country' => (bool)$w->in_country,
|
||||||
|
'visa_status' => $visaStatus,
|
||||||
|
'preferred_job_type' => $preferredJobType,
|
||||||
|
'fcm_token' => $w->fcm_token,
|
||||||
|
'passport_status' => $w->passport_status,
|
||||||
|
'emirates_id_status' => $emiratesIdStatus,
|
||||||
'document_expiry_days' => $w->document_expiry_days,
|
'document_expiry_days' => $w->document_expiry_days,
|
||||||
'document_expiry_status' => $w->document_expiry_status,
|
'document_expiry_status' => $w->document_expiry_status,
|
||||||
|
'visa_expiry_date' => $w->visa_expiry_date,
|
||||||
|
'bio' => $w->bio,
|
||||||
|
'photo' => $photo,
|
||||||
|
'religion' => $w->religion,
|
||||||
|
'rating' => $rating,
|
||||||
|
'reviews_count' => $reviewsCount,
|
||||||
|
'skills' => $w->skills->map(function ($s) {
|
||||||
|
return [
|
||||||
|
'id' => $s->id,
|
||||||
|
'name' => $s->name,
|
||||||
|
'created_at' => $s->created_at?->toISOString(),
|
||||||
|
'updated_at' => $s->updated_at?->toISOString(),
|
||||||
|
'image_path' => $s->image_path,
|
||||||
|
'pivot' => [
|
||||||
|
'worker_id' => $s->pivot->worker_id,
|
||||||
|
'skill_id' => $s->pivot->skill_id,
|
||||||
|
]
|
||||||
|
];
|
||||||
|
})->toArray(),
|
||||||
|
'documents' => $w->documents->map(function ($doc) {
|
||||||
|
return [
|
||||||
|
'id' => $doc->id,
|
||||||
|
'worker_id' => $doc->worker_id,
|
||||||
|
'type' => $doc->type,
|
||||||
|
'number' => $doc->number,
|
||||||
|
'issue_date' => $doc->issue_date,
|
||||||
|
'expiry_date' => $doc->expiry_date,
|
||||||
|
'ocr_accuracy' => $doc->ocr_accuracy,
|
||||||
|
'file_path' => $doc->file_path ? url($doc->file_path) : null,
|
||||||
|
'ocr_data' => $doc->ocr_data,
|
||||||
|
'created_at' => $doc->created_at?->toISOString(),
|
||||||
|
'updated_at' => $doc->updated_at?->toISOString(),
|
||||||
|
];
|
||||||
|
})->toArray(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,7 +171,8 @@ public function getWorkers(Request $request)
|
|||||||
$workersArray = array_values(array_filter($workersArray, function ($c) use ($skillsArray) {
|
$workersArray = array_values(array_filter($workersArray, function ($c) use ($skillsArray) {
|
||||||
if (!isset($c['skills']) || !is_array($c['skills'])) return false;
|
if (!isset($c['skills']) || !is_array($c['skills'])) return false;
|
||||||
foreach ($c['skills'] as $s) {
|
foreach ($c['skills'] as $s) {
|
||||||
if (in_array(strtolower($s), $skillsArray)) {
|
$skillName = is_array($s) ? ($s['name'] ?? '') : (is_object($s) ? ($s->name ?? '') : $s);
|
||||||
|
if (in_array(strtolower($skillName), $skillsArray)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -314,10 +344,22 @@ public function getWorkers(Request $request)
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$page = (int)$request->input('page', 1);
|
||||||
|
$perPage = (int)$request->input('per_page', 15);
|
||||||
|
$total = count($workersArray);
|
||||||
|
$offset = ($page - 1) * $perPage;
|
||||||
|
$paginatedWorkers = array_slice($workersArray, $offset, $perPage);
|
||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'success' => true,
|
'success' => true,
|
||||||
'data' => [
|
'data' => [
|
||||||
'workers' => $workersArray
|
'workers' => $paginatedWorkers,
|
||||||
|
'pagination' => [
|
||||||
|
'total' => $total,
|
||||||
|
'per_page' => $perPage,
|
||||||
|
'current_page' => $page,
|
||||||
|
'last_page' => max(1, (int)ceil($total / $perPage)),
|
||||||
|
]
|
||||||
]
|
]
|
||||||
], 200);
|
], 200);
|
||||||
|
|
||||||
@ -987,7 +1029,7 @@ public function getShortlist(Request $request)
|
|||||||
$perPage = (int)$request->input('per_page', 15);
|
$perPage = (int)$request->input('per_page', 15);
|
||||||
|
|
||||||
$shortlists = Shortlist::where('employer_id', $employer->id)
|
$shortlists = Shortlist::where('employer_id', $employer->id)
|
||||||
->with(['worker.skills'])
|
->with(['worker.skills', 'worker.documents'])
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
$formattedWorkers = $shortlists->map(function ($s) {
|
$formattedWorkers = $shortlists->map(function ($s) {
|
||||||
|
|||||||
@ -261,14 +261,6 @@ public function setupProfile(Request $request)
|
|||||||
return $worker;
|
return $worker;
|
||||||
});
|
});
|
||||||
|
|
||||||
if ($request->filled('fcm_token')) {
|
|
||||||
\App\Services\FCMService::sendPushNotification(
|
|
||||||
$request->fcm_token,
|
|
||||||
'Welcome to Migrant',
|
|
||||||
'Registration complete! Welcome to Migrant.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clear the OTP verification gate
|
// Clear the OTP verification gate
|
||||||
Cache::forget('worker_otp_verified_' . $identifier);
|
Cache::forget('worker_otp_verified_' . $identifier);
|
||||||
|
|
||||||
@ -499,14 +491,6 @@ public function register(Request $request)
|
|||||||
return $worker;
|
return $worker;
|
||||||
});
|
});
|
||||||
|
|
||||||
if ($request->filled('fcm_token')) {
|
|
||||||
\App\Services\FCMService::sendPushNotification(
|
|
||||||
$request->fcm_token,
|
|
||||||
'Welcome to Migrant',
|
|
||||||
'Worker registered successfully.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$result->load(['skills', 'documents']);
|
$result->load(['skills', 'documents']);
|
||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
|
|||||||
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('employer_profiles', function (Blueprint $table) {
|
||||||
|
$table->string('company_name')->nullable()->change();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('employer_profiles', function (Blueprint $table) {
|
||||||
|
$table->string('company_name')->nullable(false)->change();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"openapi": "3.0.0",
|
"openapi": "3.0.0",
|
||||||
"info": {
|
"info": {
|
||||||
"title": "Migrant Mobile API",
|
"title": "Migrant Mobile API",
|
||||||
@ -3580,11 +3580,66 @@
|
|||||||
"tags": [
|
"tags": [
|
||||||
"Employer/Profile"
|
"Employer/Profile"
|
||||||
],
|
],
|
||||||
"summary": "Get Profile details (Employer)",
|
"summary": "Get Employer Profile Details",
|
||||||
"description": "Retrieves the authenticated employer's profile details including their selected company name, phone, language preference, and notification settings.",
|
"description": "Retrieves the authenticated employer's profile details.",
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "Employer profile details retrieved successfully."
|
"description": "Profile retrieved successfully.",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"success": {
|
||||||
|
"type": "boolean",
|
||||||
|
"example": true
|
||||||
|
},
|
||||||
|
"data": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"profile": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"name": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "Ahmad"
|
||||||
|
},
|
||||||
|
"email": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "ahmad@example.com"
|
||||||
|
},
|
||||||
|
"phone": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "+971509990001"
|
||||||
|
},
|
||||||
|
"address": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "Villa 12, Jumeirah 2"
|
||||||
|
},
|
||||||
|
"notifications": {
|
||||||
|
"type": "boolean",
|
||||||
|
"example": true
|
||||||
|
},
|
||||||
|
"verification_status": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "approved"
|
||||||
|
},
|
||||||
|
"emirates_id_number": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "784-1988-5310327-2"
|
||||||
|
},
|
||||||
|
"emirates_id_expiry": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "2028-04-11"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3594,8 +3649,8 @@
|
|||||||
"tags": [
|
"tags": [
|
||||||
"Employer/Profile"
|
"Employer/Profile"
|
||||||
],
|
],
|
||||||
"summary": "Update Profile details (Employer)",
|
"summary": "Update Employer Profile Details",
|
||||||
"description": "Allows employers to update their profile details (company name, phone number, name, email, language preference, and notification settings) and change their account password.",
|
"description": "Updates the authenticated employer's profile details.",
|
||||||
"requestBody": {
|
"requestBody": {
|
||||||
"required": true,
|
"required": true,
|
||||||
"content": {
|
"content": {
|
||||||
@ -3606,8 +3661,7 @@
|
|||||||
"name",
|
"name",
|
||||||
"email",
|
"email",
|
||||||
"phone",
|
"phone",
|
||||||
"company_name",
|
"address",
|
||||||
"language",
|
|
||||||
"notifications"
|
"notifications"
|
||||||
],
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
@ -3623,19 +3677,9 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "+971509990001"
|
"example": "+971509990001"
|
||||||
},
|
},
|
||||||
"company_name": {
|
"address": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "Ahmad Tech Ltd"
|
"example": "Villa 12, Jumeirah 2"
|
||||||
},
|
|
||||||
"language": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"English",
|
|
||||||
"Arabic",
|
|
||||||
"english",
|
|
||||||
"arabic"
|
|
||||||
],
|
|
||||||
"example": "English"
|
|
||||||
},
|
},
|
||||||
"notifications": {
|
"notifications": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
@ -3665,7 +3709,69 @@
|
|||||||
},
|
},
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "Profile updated successfully."
|
"description": "Profile updated successfully.",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"success": {
|
||||||
|
"type": "boolean",
|
||||||
|
"example": true
|
||||||
|
},
|
||||||
|
"message": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "Profile updated successfully."
|
||||||
|
},
|
||||||
|
"data": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"profile": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"name": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "Ahmad"
|
||||||
|
},
|
||||||
|
"email": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "ahmad@example.com"
|
||||||
|
},
|
||||||
|
"phone": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "+971509990001"
|
||||||
|
},
|
||||||
|
"address": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "Villa 12, Jumeirah 2"
|
||||||
|
},
|
||||||
|
"notifications": {
|
||||||
|
"type": "boolean",
|
||||||
|
"example": true
|
||||||
|
},
|
||||||
|
"verification_status": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "approved"
|
||||||
|
},
|
||||||
|
"emirates_id_number": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "784-1988-5310327-2"
|
||||||
|
},
|
||||||
|
"emirates_id_expiry": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "2028-04-11"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"422": {
|
||||||
|
"description": "Validation error."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3818,7 +3924,52 @@
|
|||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "Available workers list retrieved successfully."
|
"description": "Available workers list retrieved successfully.",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"success": {
|
||||||
|
"type": "boolean",
|
||||||
|
"example": true
|
||||||
|
},
|
||||||
|
"data": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"workers": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/Worker"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"pagination": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"total": {
|
||||||
|
"type": "integer",
|
||||||
|
"example": 12
|
||||||
|
},
|
||||||
|
"per_page": {
|
||||||
|
"type": "integer",
|
||||||
|
"example": 15
|
||||||
|
},
|
||||||
|
"current_page": {
|
||||||
|
"type": "integer",
|
||||||
|
"example": 1
|
||||||
|
},
|
||||||
|
"last_page": {
|
||||||
|
"type": "integer",
|
||||||
|
"example": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5306,6 +5457,13 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "HI"
|
"example": "HI"
|
||||||
},
|
},
|
||||||
|
"languages": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"example": ["English", "Arabic"]
|
||||||
|
},
|
||||||
"fcm_token": {
|
"fcm_token": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "fcm_token_example"
|
"example": "fcm_token_example"
|
||||||
@ -5362,6 +5520,19 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "Passport Verified"
|
"example": "Passport Verified"
|
||||||
},
|
},
|
||||||
|
"document_expiry_days": {
|
||||||
|
"type": "integer",
|
||||||
|
"example": -857
|
||||||
|
},
|
||||||
|
"document_expiry_status": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "Visa Expired"
|
||||||
|
},
|
||||||
|
"visa_expiry_date": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "date",
|
||||||
|
"example": "2024-02-15"
|
||||||
|
},
|
||||||
"preferred_job_type": {
|
"preferred_job_type": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "full-time"
|
"example": "full-time"
|
||||||
@ -5395,6 +5566,19 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "Marina"
|
"example": "Marina"
|
||||||
},
|
},
|
||||||
|
"rating": {
|
||||||
|
"type": "number",
|
||||||
|
"example": 4.5
|
||||||
|
},
|
||||||
|
"reviews_count": {
|
||||||
|
"type": "integer",
|
||||||
|
"example": 2
|
||||||
|
},
|
||||||
|
"photo": {
|
||||||
|
"type": "string",
|
||||||
|
"nullable": true,
|
||||||
|
"example": "https://example.com/photo.jpg"
|
||||||
|
},
|
||||||
"created_at": {
|
"created_at": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"format": "date-time",
|
"format": "date-time",
|
||||||
@ -5405,6 +5589,12 @@
|
|||||||
"format": "date-time",
|
"format": "date-time",
|
||||||
"example": "2026-05-20T14:54:26.000000Z"
|
"example": "2026-05-20T14:54:26.000000Z"
|
||||||
},
|
},
|
||||||
|
"deleted_at": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "date-time",
|
||||||
|
"nullable": true,
|
||||||
|
"example": null
|
||||||
|
},
|
||||||
"category": {
|
"category": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@ -5430,6 +5620,32 @@
|
|||||||
"name": {
|
"name": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "Cleaning"
|
"example": "Cleaning"
|
||||||
|
},
|
||||||
|
"created_at": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "date-time"
|
||||||
|
},
|
||||||
|
"updated_at": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "date-time"
|
||||||
|
},
|
||||||
|
"image_path": {
|
||||||
|
"type": "string",
|
||||||
|
"nullable": true,
|
||||||
|
"example": "skills/cleaning.png"
|
||||||
|
},
|
||||||
|
"pivot": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"worker_id": {
|
||||||
|
"type": "integer",
|
||||||
|
"example": 136
|
||||||
|
},
|
||||||
|
"skill_id": {
|
||||||
|
"type": "integer",
|
||||||
|
"example": 6
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5477,7 +5693,21 @@
|
|||||||
},
|
},
|
||||||
"file_path": {
|
"file_path": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
"nullable": true,
|
||||||
"example": "uploads/documents/1716200000_passport_my_file.jpg"
|
"example": "uploads/documents/1716200000_passport_my_file.jpg"
|
||||||
|
},
|
||||||
|
"ocr_data": {
|
||||||
|
"type": "object",
|
||||||
|
"nullable": true,
|
||||||
|
"description": "OCR raw parsed data or confidence data"
|
||||||
|
},
|
||||||
|
"created_at": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "date-time"
|
||||||
|
},
|
||||||
|
"updated_at": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "date-time"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -30,10 +30,9 @@ protected function setUp(): void
|
|||||||
|
|
||||||
EmployerProfile::create([
|
EmployerProfile::create([
|
||||||
'user_id' => $this->employer->id,
|
'user_id' => $this->employer->id,
|
||||||
'company_name' => 'Original Company',
|
'address' => 'Original Address',
|
||||||
'phone' => '+971501112222',
|
'phone' => '+971501112222',
|
||||||
'verification_status' => 'approved',
|
'verification_status' => 'approved',
|
||||||
'language' => 'English',
|
|
||||||
'notifications' => true,
|
'notifications' => true,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@ -54,9 +53,8 @@ public function test_employer_can_get_profile()
|
|||||||
'profile' => [
|
'profile' => [
|
||||||
'name',
|
'name',
|
||||||
'email',
|
'email',
|
||||||
'company_name',
|
|
||||||
'phone',
|
'phone',
|
||||||
'language',
|
'address',
|
||||||
'notifications',
|
'notifications',
|
||||||
'verification_status',
|
'verification_status',
|
||||||
]
|
]
|
||||||
@ -64,7 +62,7 @@ public function test_employer_can_get_profile()
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertEquals('Original Name', $response->json('data.profile.name'));
|
$this->assertEquals('Original Name', $response->json('data.profile.name'));
|
||||||
$this->assertEquals('Original Company', $response->json('data.profile.company_name'));
|
$this->assertEquals('Original Address', $response->json('data.profile.address'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -78,8 +76,7 @@ public function test_employer_can_update_profile()
|
|||||||
'name' => 'Updated Name',
|
'name' => 'Updated Name',
|
||||||
'email' => 'employer_updated@example.com',
|
'email' => 'employer_updated@example.com',
|
||||||
'phone' => '+971509999999',
|
'phone' => '+971509999999',
|
||||||
'company_name' => 'Updated Company Corp',
|
'address' => 'Updated Address Info',
|
||||||
'language' => 'Arabic',
|
|
||||||
'notifications' => false,
|
'notifications' => false,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -91,9 +88,8 @@ public function test_employer_can_update_profile()
|
|||||||
'profile' => [
|
'profile' => [
|
||||||
'name',
|
'name',
|
||||||
'email',
|
'email',
|
||||||
'company_name',
|
|
||||||
'phone',
|
'phone',
|
||||||
'language',
|
'address',
|
||||||
'notifications',
|
'notifications',
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
@ -107,8 +103,7 @@ public function test_employer_can_update_profile()
|
|||||||
|
|
||||||
$this->assertDatabaseHas('employer_profiles', [
|
$this->assertDatabaseHas('employer_profiles', [
|
||||||
'user_id' => $this->employer->id,
|
'user_id' => $this->employer->id,
|
||||||
'company_name' => 'Updated Company Corp',
|
'address' => 'Updated Address Info',
|
||||||
'language' => 'Arabic',
|
|
||||||
'notifications' => false,
|
'notifications' => false,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@ -124,8 +119,7 @@ public function test_employer_can_update_password()
|
|||||||
'name' => 'Original Name',
|
'name' => 'Original Name',
|
||||||
'email' => 'employer@example.com',
|
'email' => 'employer@example.com',
|
||||||
'phone' => '+971501112222',
|
'phone' => '+971501112222',
|
||||||
'company_name' => 'Original Company',
|
'address' => 'Original Address',
|
||||||
'language' => 'English',
|
|
||||||
'notifications' => true,
|
'notifications' => true,
|
||||||
'current_password' => 'Password@123',
|
'current_password' => 'Password@123',
|
||||||
'new_password' => 'NewSecurePassword@123',
|
'new_password' => 'NewSecurePassword@123',
|
||||||
@ -149,8 +143,7 @@ public function test_employer_password_update_fails_with_incorrect_current_passw
|
|||||||
'name' => 'Original Name',
|
'name' => 'Original Name',
|
||||||
'email' => 'employer@example.com',
|
'email' => 'employer@example.com',
|
||||||
'phone' => '+971501112222',
|
'phone' => '+971501112222',
|
||||||
'company_name' => 'Original Company',
|
'address' => 'Original Address',
|
||||||
'language' => 'English',
|
|
||||||
'notifications' => true,
|
'notifications' => true,
|
||||||
'current_password' => 'WrongCurrentPassword',
|
'current_password' => 'WrongCurrentPassword',
|
||||||
'new_password' => 'NewSecurePassword@123',
|
'new_password' => 'NewSecurePassword@123',
|
||||||
|
|||||||
@ -435,11 +435,101 @@ public function test_worker_list_includes_document_expiry_status()
|
|||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
$workers = $response->json('data.workers');
|
$workers = $response->json('data.workers');
|
||||||
|
|
||||||
// Find the worker we just created in the response
|
|
||||||
$matchingWorker = collect($workers)->firstWhere('id', $worker->id);
|
$matchingWorker = collect($workers)->firstWhere('id', $worker->id);
|
||||||
|
|
||||||
$this->assertNotNull($matchingWorker);
|
$this->assertNotNull($matchingWorker);
|
||||||
$this->assertEquals(45, $matchingWorker['document_expiry_days']);
|
$this->assertEquals(45, $matchingWorker['document_expiry_days']);
|
||||||
$this->assertEquals('Visa expires in 45 days', $matchingWorker['document_expiry_status']);
|
$this->assertEquals('Visa expires in 45 days', $matchingWorker['document_expiry_status']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_worker_list_api_has_full_details_and_pagination()
|
||||||
|
{
|
||||||
|
$worker = Worker::create([
|
||||||
|
'name' => 'Full Detail Worker',
|
||||||
|
'email' => 'full_detail@example.com',
|
||||||
|
'phone' => '+971509999888',
|
||||||
|
'password' => bcrypt('password'),
|
||||||
|
'nationality' => 'Indian',
|
||||||
|
'verified' => true,
|
||||||
|
'status' => 'active',
|
||||||
|
'preferred_location' => 'Dubai Marina',
|
||||||
|
'live_in_out' => 'live_out',
|
||||||
|
'gender' => 'male',
|
||||||
|
'in_country' => true,
|
||||||
|
'visa_status' => 'Tourist Visa',
|
||||||
|
'preferred_job_type' => 'full-time',
|
||||||
|
'fcm_token' => 'fcm_token_example',
|
||||||
|
'age' => 36,
|
||||||
|
'salary' => 1500.00,
|
||||||
|
'experience' => '4 Years',
|
||||||
|
'language' => 'English, Arabic',
|
||||||
|
'availability' => 'Immediate',
|
||||||
|
'religion' => 'Christian',
|
||||||
|
'bio' => 'Experienced helper',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$doc1 = WorkerDocument::create([
|
||||||
|
'worker_id' => $worker->id,
|
||||||
|
'type' => 'passport',
|
||||||
|
'number' => 'YB98239279327',
|
||||||
|
'issue_date' => '2017-07-05',
|
||||||
|
'expiry_date' => '2022-07-05',
|
||||||
|
'ocr_accuracy' => 99,
|
||||||
|
'ocr_data' => ['authority' => 'FMP LLC'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$doc2 = WorkerDocument::create([
|
||||||
|
'worker_id' => $worker->id,
|
||||||
|
'type' => 'visa',
|
||||||
|
'number' => '343434',
|
||||||
|
'issue_date' => '2022-02-16',
|
||||||
|
'expiry_date' => '2024-02-15',
|
||||||
|
'ocr_accuracy' => 99,
|
||||||
|
'ocr_data' => ['sponsor' => 'string'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Add a skill
|
||||||
|
$skill = \App\Models\Skill::firstOrCreate(['name' => 'Ironing']);
|
||||||
|
$worker->skills()->attach($skill->id);
|
||||||
|
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'Authorization' => 'Bearer ' . $this->token,
|
||||||
|
])->getJson('/api/employers/workers?page=1&per_page=15');
|
||||||
|
|
||||||
|
$response->assertStatus(200);
|
||||||
|
$response->assertJsonStructure([
|
||||||
|
'success',
|
||||||
|
'data' => [
|
||||||
|
'workers',
|
||||||
|
'pagination' => [
|
||||||
|
'total',
|
||||||
|
'per_page',
|
||||||
|
'current_page',
|
||||||
|
'last_page',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$workers = $response->json('data.workers');
|
||||||
|
$matchingWorker = collect($workers)->firstWhere('id', $worker->id);
|
||||||
|
|
||||||
|
$this->assertNotNull($matchingWorker);
|
||||||
|
$this->assertEquals('+971509999888', $matchingWorker['phone']);
|
||||||
|
$this->assertEquals('1500.00', $matchingWorker['salary']);
|
||||||
|
$this->assertEquals('active', $matchingWorker['status']);
|
||||||
|
$this->assertEquals('English, Arabic', $matchingWorker['language']);
|
||||||
|
$this->assertEquals('fcm_token_example', $matchingWorker['fcm_token']);
|
||||||
|
$this->assertEquals('2024-02-15', $matchingWorker['visa_expiry_date']);
|
||||||
|
|
||||||
|
// Check skills object array
|
||||||
|
$this->assertIsArray($matchingWorker['skills']);
|
||||||
|
$this->assertCount(1, $matchingWorker['skills']);
|
||||||
|
$this->assertEquals('Ironing', $matchingWorker['skills'][0]['name']);
|
||||||
|
|
||||||
|
// Check documents object array
|
||||||
|
$this->assertIsArray($matchingWorker['documents']);
|
||||||
|
$this->assertCount(2, $matchingWorker['documents']);
|
||||||
|
$this->assertEquals('passport', $matchingWorker['documents'][0]['type']);
|
||||||
|
$this->assertEquals('visa', $matchingWorker['documents'][1]['type']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user