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([
|
||||
'success' => true,
|
||||
'message' => 'Password created successfully. Registration finalized.',
|
||||
|
||||
@ -28,8 +28,8 @@ public function getProfile(Request $request)
|
||||
if (!$profile) {
|
||||
$profile = EmployerProfile::create([
|
||||
'user_id' => $employer->id,
|
||||
'company_name' => 'Al Mansoor Household',
|
||||
'phone' => '+971 50 123 4567',
|
||||
'address' => 'Dubai, UAE',
|
||||
'verification_status' => 'approved',
|
||||
]);
|
||||
}
|
||||
@ -37,9 +37,8 @@ public function getProfile(Request $request)
|
||||
$employerProfile = [
|
||||
'name' => $employer->name,
|
||||
'email' => $employer->email,
|
||||
'company_name' => $profile->company_name,
|
||||
'phone' => $profile->phone,
|
||||
'language' => $profile->language ?? 'English',
|
||||
'address' => $profile->address,
|
||||
'notifications' => (bool)($profile->notifications ?? true),
|
||||
'verification_status' => $profile->verification_status ?? 'approved',
|
||||
'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'),
|
||||
$sponsor ? 'unique:sponsors,mobile,' . $sponsor->id : 'unique:sponsors,mobile',
|
||||
],
|
||||
'company_name' => 'required|string|max:255',
|
||||
'language' => 'required|string|in:English,Arabic,english,arabic',
|
||||
'address' => 'required|string|max:255',
|
||||
'notifications' => 'required|boolean',
|
||||
'current_password' => 'nullable|required_with:new_password|string',
|
||||
'new_password' => 'nullable|string|min:8|confirmed',
|
||||
@ -144,6 +142,7 @@ public function updateProfile(Request $request)
|
||||
'full_name' => $request->name,
|
||||
'email' => $request->email,
|
||||
'mobile' => $request->phone,
|
||||
'address' => $request->address,
|
||||
]);
|
||||
}
|
||||
|
||||
@ -152,9 +151,8 @@ public function updateProfile(Request $request)
|
||||
if (!$profile) {
|
||||
$profile = new EmployerProfile(['user_id' => $employer->id]);
|
||||
}
|
||||
$profile->company_name = $request->company_name;
|
||||
$profile->address = $request->address;
|
||||
$profile->phone = $request->phone;
|
||||
$profile->language = ucfirst(strtolower($request->language));
|
||||
$profile->notifications = $request->notifications;
|
||||
$profile->save();
|
||||
|
||||
@ -168,9 +166,8 @@ public function updateProfile(Request $request)
|
||||
$employerProfile = [
|
||||
'name' => $employer->name,
|
||||
'email' => $employer->email,
|
||||
'company_name' => $profile->company_name,
|
||||
'phone' => $profile->phone,
|
||||
'language' => $profile->language,
|
||||
'address' => $profile->address,
|
||||
'notifications' => (bool)$profile->notifications,
|
||||
'verification_status' => $profile->verification_status ?? 'approved',
|
||||
'emirates_id_number' => $profile->emirates_id_number,
|
||||
|
||||
@ -22,23 +22,16 @@ class EmployerWorkerController extends Controller
|
||||
*/
|
||||
private function formatWorker(Worker $w)
|
||||
{
|
||||
// Map languages with country names
|
||||
$langs = ($w->id % 2 === 0) ? ['English', 'Arabic'] : (($w->id % 3 === 0) ? ['English', 'Tagalog'] : ['English', 'Hindi', 'Arabic']);
|
||||
// Map languages from database comma-separated string
|
||||
$langs = $w->language ? array_map('trim', explode(',', $w->language)) : ['English'];
|
||||
|
||||
// Preferred job types: 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];
|
||||
|
||||
// Emirates ID verification status (dynamic passport status)
|
||||
// Emirates ID verification 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
|
||||
$visaStatus = $w->visa_status;
|
||||
|
||||
@ -51,28 +44,64 @@ private function formatWorker(Worker $w)
|
||||
return [
|
||||
'id' => $w->id,
|
||||
'name' => $w->name,
|
||||
'phone' => $w->phone,
|
||||
'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,
|
||||
'gender' => $w->gender,
|
||||
'salary' => $w->salary,
|
||||
'experience' => $w->experience,
|
||||
'verified' => (bool)$w->verified,
|
||||
'preferred_job_type' => $preferredJobType,
|
||||
'bio' => $w->bio,
|
||||
'rating' => $rating,
|
||||
'reviews_count' => $reviewsCount,
|
||||
'status' => $w->status,
|
||||
'created_at' => $w->created_at?->toISOString(),
|
||||
'updated_at' => $w->updated_at?->toISOString(),
|
||||
'deleted_at' => $w->deleted_at?->toISOString(),
|
||||
'language' => $w->language,
|
||||
'languages' => $langs,
|
||||
'preferred_location' => $w->preferred_location,
|
||||
'area' => $w->area,
|
||||
'live_in_out' => $w->live_in_out,
|
||||
'gender' => $w->gender,
|
||||
'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_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) {
|
||||
if (!isset($c['skills']) || !is_array($c['skills'])) return false;
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -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([
|
||||
'success' => true,
|
||||
'data' => [
|
||||
'workers' => $workersArray
|
||||
'workers' => $paginatedWorkers,
|
||||
'pagination' => [
|
||||
'total' => $total,
|
||||
'per_page' => $perPage,
|
||||
'current_page' => $page,
|
||||
'last_page' => max(1, (int)ceil($total / $perPage)),
|
||||
]
|
||||
]
|
||||
], 200);
|
||||
|
||||
@ -987,7 +1029,7 @@ public function getShortlist(Request $request)
|
||||
$perPage = (int)$request->input('per_page', 15);
|
||||
|
||||
$shortlists = Shortlist::where('employer_id', $employer->id)
|
||||
->with(['worker.skills'])
|
||||
->with(['worker.skills', 'worker.documents'])
|
||||
->get();
|
||||
|
||||
$formattedWorkers = $shortlists->map(function ($s) {
|
||||
|
||||
@ -261,14 +261,6 @@ public function setupProfile(Request $request)
|
||||
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
|
||||
Cache::forget('worker_otp_verified_' . $identifier);
|
||||
|
||||
@ -499,14 +491,6 @@ public function register(Request $request)
|
||||
return $worker;
|
||||
});
|
||||
|
||||
if ($request->filled('fcm_token')) {
|
||||
\App\Services\FCMService::sendPushNotification(
|
||||
$request->fcm_token,
|
||||
'Welcome to Migrant',
|
||||
'Worker registered successfully.'
|
||||
);
|
||||
}
|
||||
|
||||
$result->load(['skills', 'documents']);
|
||||
|
||||
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",
|
||||
"info": {
|
||||
"title": "Migrant Mobile API",
|
||||
@ -3580,11 +3580,66 @@
|
||||
"tags": [
|
||||
"Employer/Profile"
|
||||
],
|
||||
"summary": "Get Profile details (Employer)",
|
||||
"description": "Retrieves the authenticated employer's profile details including their selected company name, phone, language preference, and notification settings.",
|
||||
"summary": "Get Employer Profile Details",
|
||||
"description": "Retrieves the authenticated employer's profile details.",
|
||||
"responses": {
|
||||
"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": [
|
||||
"Employer/Profile"
|
||||
],
|
||||
"summary": "Update Profile details (Employer)",
|
||||
"description": "Allows employers to update their profile details (company name, phone number, name, email, language preference, and notification settings) and change their account password.",
|
||||
"summary": "Update Employer Profile Details",
|
||||
"description": "Updates the authenticated employer's profile details.",
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
@ -3606,8 +3661,7 @@
|
||||
"name",
|
||||
"email",
|
||||
"phone",
|
||||
"company_name",
|
||||
"language",
|
||||
"address",
|
||||
"notifications"
|
||||
],
|
||||
"properties": {
|
||||
@ -3623,19 +3677,9 @@
|
||||
"type": "string",
|
||||
"example": "+971509990001"
|
||||
},
|
||||
"company_name": {
|
||||
"address": {
|
||||
"type": "string",
|
||||
"example": "Ahmad Tech Ltd"
|
||||
},
|
||||
"language": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"English",
|
||||
"Arabic",
|
||||
"english",
|
||||
"arabic"
|
||||
],
|
||||
"example": "English"
|
||||
"example": "Villa 12, Jumeirah 2"
|
||||
},
|
||||
"notifications": {
|
||||
"type": "boolean",
|
||||
@ -3665,7 +3709,69 @@
|
||||
},
|
||||
"responses": {
|
||||
"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": {
|
||||
"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",
|
||||
"example": "HI"
|
||||
},
|
||||
"languages": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"example": ["English", "Arabic"]
|
||||
},
|
||||
"fcm_token": {
|
||||
"type": "string",
|
||||
"example": "fcm_token_example"
|
||||
@ -5362,6 +5520,19 @@
|
||||
"type": "string",
|
||||
"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": {
|
||||
"type": "string",
|
||||
"example": "full-time"
|
||||
@ -5395,6 +5566,19 @@
|
||||
"type": "string",
|
||||
"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": {
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
@ -5405,6 +5589,12 @@
|
||||
"format": "date-time",
|
||||
"example": "2026-05-20T14:54:26.000000Z"
|
||||
},
|
||||
"deleted_at": {
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
"nullable": true,
|
||||
"example": null
|
||||
},
|
||||
"category": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@ -5430,6 +5620,32 @@
|
||||
"name": {
|
||||
"type": "string",
|
||||
"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": {
|
||||
"type": "string",
|
||||
"nullable": true,
|
||||
"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([
|
||||
'user_id' => $this->employer->id,
|
||||
'company_name' => 'Original Company',
|
||||
'address' => 'Original Address',
|
||||
'phone' => '+971501112222',
|
||||
'verification_status' => 'approved',
|
||||
'language' => 'English',
|
||||
'notifications' => true,
|
||||
]);
|
||||
}
|
||||
@ -54,9 +53,8 @@ public function test_employer_can_get_profile()
|
||||
'profile' => [
|
||||
'name',
|
||||
'email',
|
||||
'company_name',
|
||||
'phone',
|
||||
'language',
|
||||
'address',
|
||||
'notifications',
|
||||
'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 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',
|
||||
'email' => 'employer_updated@example.com',
|
||||
'phone' => '+971509999999',
|
||||
'company_name' => 'Updated Company Corp',
|
||||
'language' => 'Arabic',
|
||||
'address' => 'Updated Address Info',
|
||||
'notifications' => false,
|
||||
]);
|
||||
|
||||
@ -91,9 +88,8 @@ public function test_employer_can_update_profile()
|
||||
'profile' => [
|
||||
'name',
|
||||
'email',
|
||||
'company_name',
|
||||
'phone',
|
||||
'language',
|
||||
'address',
|
||||
'notifications',
|
||||
]
|
||||
]
|
||||
@ -107,8 +103,7 @@ public function test_employer_can_update_profile()
|
||||
|
||||
$this->assertDatabaseHas('employer_profiles', [
|
||||
'user_id' => $this->employer->id,
|
||||
'company_name' => 'Updated Company Corp',
|
||||
'language' => 'Arabic',
|
||||
'address' => 'Updated Address Info',
|
||||
'notifications' => false,
|
||||
]);
|
||||
}
|
||||
@ -124,8 +119,7 @@ public function test_employer_can_update_password()
|
||||
'name' => 'Original Name',
|
||||
'email' => 'employer@example.com',
|
||||
'phone' => '+971501112222',
|
||||
'company_name' => 'Original Company',
|
||||
'language' => 'English',
|
||||
'address' => 'Original Address',
|
||||
'notifications' => true,
|
||||
'current_password' => 'Password@123',
|
||||
'new_password' => 'NewSecurePassword@123',
|
||||
@ -149,8 +143,7 @@ public function test_employer_password_update_fails_with_incorrect_current_passw
|
||||
'name' => 'Original Name',
|
||||
'email' => 'employer@example.com',
|
||||
'phone' => '+971501112222',
|
||||
'company_name' => 'Original Company',
|
||||
'language' => 'English',
|
||||
'address' => 'Original Address',
|
||||
'notifications' => true,
|
||||
'current_password' => 'WrongCurrentPassword',
|
||||
'new_password' => 'NewSecurePassword@123',
|
||||
|
||||
@ -435,11 +435,101 @@ public function test_worker_list_includes_document_expiry_status()
|
||||
$response->assertStatus(200);
|
||||
$workers = $response->json('data.workers');
|
||||
|
||||
// Find the worker we just created in the response
|
||||
$matchingWorker = collect($workers)->firstWhere('id', $worker->id);
|
||||
|
||||
$this->assertNotNull($matchingWorker);
|
||||
$this->assertEquals(45, $matchingWorker['document_expiry_days']);
|
||||
$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