diff --git a/app/Http/Controllers/Api/WorkerAuthController.php b/app/Http/Controllers/Api/WorkerAuthController.php index 76143cb..847093c 100644 --- a/app/Http/Controllers/Api/WorkerAuthController.php +++ b/app/Http/Controllers/Api/WorkerAuthController.php @@ -170,13 +170,16 @@ public function verifyOtp(Request $request) public function setupProfile(Request $request) { $validator = Validator::make($request->all(), [ - 'phone' => 'required_without:email|nullable|string|max:50', - 'email' => 'required_without:phone|nullable|email|max:255', - 'name' => 'required|string|max:255', - 'nationality' => 'required|string|max:100', - 'language' => 'nullable|string', - 'skills' => 'nullable|array', - 'skills.*' => 'integer|exists:skills,id', + 'phone' => 'required_without:email|nullable|string|max:50', + 'email' => 'required_without:phone|nullable|email|max:255', + 'name' => 'required|string|max:255', + 'nationality' => 'required|string|max:100', + 'language' => 'nullable|string', + 'gender' => 'nullable|string|in:male,female,other', + 'live_in_out' => 'nullable|string|in:live_in,live_out', + 'preferred_location' => 'nullable|string|max:255', + 'skills' => 'nullable|array', + 'skills.*' => 'integer|exists:skills,id', ]); if ($validator->fails()) { @@ -225,22 +228,25 @@ public function setupProfile(Request $request) $worker = DB::transaction(function () use ($request, $email, $apiToken) { $worker = Worker::create([ - 'name' => $request->name, - 'email' => $email, - 'phone' => $request->phone ?? null, - 'language' => $request->language ?? 'HI', // Default to Hindi if not selected - 'password' => Hash::make(Str::random(16)), // No password at this stage - 'nationality' => $request->nationality, - 'age' => 25, // Default — updated later in full profile - 'salary' => 1500, // Default AED — updated later - 'availability'=> 'Immediate', - 'experience' => 'Not Specified', - 'religion' => 'Not Specified', - 'bio' => 'New worker on Migrant platform.', - 'category_id' => \App\Models\WorkerCategory::where('name', 'General Helper')->value('id') ?? (\App\Models\WorkerCategory::firstOrCreate(['name' => 'General Helper'])->id), - 'verified' => false, - 'status' => 'active', - 'api_token' => $apiToken, + 'name' => $request->name, + 'email' => $email, + 'phone' => $request->phone ?? null, + 'language' => $request->language ?? 'HI', // Default to Hindi if not selected + 'password' => Hash::make(Str::random(16)), // No password at this stage + 'nationality' => $request->nationality, + 'gender' => $request->gender, + 'live_in_out' => $request->live_in_out, + 'preferred_location' => $request->preferred_location, + 'age' => 25, // Default — updated later in full profile + 'salary' => 1500, // Default AED — updated later + 'availability' => 'Immediate', + 'experience' => 'Not Specified', + 'religion' => 'Not Specified', + 'bio' => 'New worker on Migrant platform.', + 'category_id' => \App\Models\WorkerCategory::where('name', 'General Helper')->value('id') ?? (\App\Models\WorkerCategory::firstOrCreate(['name' => 'General Helper'])->id), + 'verified' => false, + 'status' => 'active', + 'api_token' => $apiToken, ]); // Sync skills if provided @@ -281,24 +287,26 @@ public function setupProfile(Request $request) public function register(Request $request) { $validator = Validator::make($request->all(), [ - 'name' => 'required|string|max:255', - 'phone' => 'required|string|max:50|unique:workers,phone', - 'salary' => 'required|numeric|min:0', - 'password' => 'required|string|min:6', - 'passport_file' => 'required|file|mimes:jpeg,png,jpg,pdf|max:10240', - 'skills' => 'nullable', - 'visa_file' => 'nullable|file|mimes:jpeg,png,jpg,pdf|max:10240', - 'language' => 'nullable|string', - 'nationality' => 'nullable|string|max:100', - 'age' => 'nullable|integer', - 'experience' => 'nullable|string|max:100', - 'in_country' => 'nullable', - 'visa_status' => 'nullable|string|max:100', + 'name' => 'required|string|max:255', + 'phone' => 'required|string|max:50|unique:workers,phone', + 'salary' => 'required|numeric|min:0', + 'password' => 'required|string|min:6', + 'passport_file' => 'required|file|mimes:jpeg,png,jpg,pdf|max:10240', + 'skills' => 'nullable', + 'visa_file' => 'nullable|file|mimes:jpeg,png,jpg,pdf|max:10240', + 'language' => 'nullable|string', + 'nationality' => 'nullable|string|max:100', + 'age' => 'nullable|integer', + 'experience' => 'nullable|string|max:100', + 'in_country' => 'nullable', + 'visa_status' => 'nullable|string|max:100', 'preferred_job_type' => 'nullable|string|max:100', - 'live_in_out' => 'nullable|string|max:100', - 'country' => 'nullable|string|max:100', - 'city' => 'nullable|string|max:100', - 'area' => 'nullable|string|max:100', + 'gender' => 'nullable|string|in:male,female,other', + 'live_in_out' => 'nullable|string|in:live_in,live_out', + 'preferred_location' => 'nullable|string|max:255', + 'country' => 'nullable|string|max:100', + 'city' => 'nullable|string|max:100', + 'area' => 'nullable|string|max:100', ]); if ($validator->fails()) { @@ -356,29 +364,31 @@ public function register(Request $request) $result = DB::transaction(function () use ($request, $email, $skillsArray, $passportPath, $visaPath, $apiToken, $inCountry) { $worker = Worker::create([ - 'name' => $request->name, - 'email' => $email, - 'phone' => $request->phone, - 'language' => $request->language ?? 'HI', - 'password' => Hash::make($request->password), - 'nationality' => $request->nationality ?? 'Not Specified', - 'age' => $request->age ?? 25, - 'salary' => $request->salary, - 'availability'=> 'Immediate', - 'experience' => $request->experience ?? 'Not Specified', - 'religion' => 'Not Specified', - 'bio' => 'Hardworking and reliable General Helper available for immediate hire.', - 'category_id' => \App\Models\WorkerCategory::where('name', 'General Helper')->value('id') ?? (\App\Models\WorkerCategory::firstOrCreate(['name' => 'General Helper'])->id), - 'verified' => false, - 'status' => 'active', - 'api_token' => $apiToken, - 'in_country' => $inCountry, - 'visa_status' => $inCountry ? $request->visa_status : null, + 'name' => $request->name, + 'email' => $email, + 'phone' => $request->phone, + 'language' => $request->language ?? 'HI', + 'password' => Hash::make($request->password), + 'nationality' => $request->nationality ?? 'Not Specified', + 'gender' => $request->gender, + 'live_in_out' => $request->live_in_out, + 'preferred_location' => $request->preferred_location, + 'age' => $request->age ?? 25, + 'salary' => $request->salary, + 'availability' => 'Immediate', + 'experience' => $request->experience ?? 'Not Specified', + 'religion' => 'Not Specified', + 'bio' => 'Hardworking and reliable General Helper available for immediate hire.', + 'category_id' => \App\Models\WorkerCategory::where('name', 'General Helper')->value('id') ?? (\App\Models\WorkerCategory::firstOrCreate(['name' => 'General Helper'])->id), + 'verified' => false, + 'status' => 'active', + 'api_token' => $apiToken, + 'in_country' => $inCountry, + 'visa_status' => $inCountry ? $request->visa_status : null, 'preferred_job_type' => $request->preferred_job_type, - 'live_in_out' => $request->live_in_out, - 'country' => $request->country, - 'city' => $request->city, - 'area' => $request->area, + 'country' => $request->country, + 'city' => $request->city, + 'area' => $request->area, ]); if (!empty($skillsArray)) { diff --git a/app/Http/Controllers/Api/WorkerProfileController.php b/app/Http/Controllers/Api/WorkerProfileController.php index fe55e87..08c38f3 100644 --- a/app/Http/Controllers/Api/WorkerProfileController.php +++ b/app/Http/Controllers/Api/WorkerProfileController.php @@ -49,25 +49,27 @@ public function updateProfile(Request $request) $worker = $request->attributes->get('worker'); $validator = Validator::make($request->all(), [ - 'name' => 'nullable|string|max:255', - 'age' => 'nullable|integer|min:18|max:70', - 'nationality' => 'nullable|string|max:100', - 'language' => 'nullable|string', - 'salary' => 'nullable|numeric|min:0', - 'availability' => 'nullable|string|max:100', - 'experience' => 'nullable|string|max:100', - 'religion' => 'nullable|string|max:100', - 'bio' => 'nullable|string|max:1000', - 'category_id' => 'nullable|exists:worker_categories,id', - 'skills' => 'nullable|array', - 'skills.*' => 'exists:skills,id', - 'in_country' => 'nullable', - 'visa_status' => 'nullable|string|max:100', + 'name' => 'nullable|string|max:255', + 'age' => 'nullable|integer|min:18|max:70', + 'nationality' => 'nullable|string|max:100', + 'language' => 'nullable|string', + 'salary' => 'nullable|numeric|min:0', + 'availability' => 'nullable|string|max:100', + 'experience' => 'nullable|string|max:100', + 'religion' => 'nullable|string|max:100', + 'bio' => 'nullable|string|max:1000', + 'category_id' => 'nullable|exists:worker_categories,id', + 'skills' => 'nullable|array', + 'skills.*' => 'exists:skills,id', + 'in_country' => 'nullable', + 'visa_status' => 'nullable|string|max:100', 'preferred_job_type' => 'nullable|string|max:100', - 'live_in_out' => 'nullable|string|max:100', - 'country' => 'nullable|string|max:100', - 'city' => 'nullable|string|max:100', - 'area' => 'nullable|string|max:100', + 'gender' => 'nullable|string|in:male,female,other', + 'live_in_out' => 'nullable|string|in:live_in,live_out', + 'preferred_location' => 'nullable|string|max:255', + 'country' => 'nullable|string|max:100', + 'city' => 'nullable|string|max:100', + 'area' => 'nullable|string|max:100', ]); if ($validator->fails()) { @@ -94,7 +96,9 @@ public function updateProfile(Request $request) 'category_id', 'visa_status', 'preferred_job_type', + 'gender', 'live_in_out', + 'preferred_location', 'country', 'city', 'area' diff --git a/app/Models/Worker.php b/app/Models/Worker.php index d8c46d2..acc8b7a 100644 --- a/app/Models/Worker.php +++ b/app/Models/Worker.php @@ -20,6 +20,7 @@ class Worker extends Model 'country', 'city', 'area', + 'preferred_location', 'live_in_out', 'age', 'gender', diff --git a/database/migrations/2026_06_08_162345_add_preferred_location_to_workers_table.php b/database/migrations/2026_06_08_162345_add_preferred_location_to_workers_table.php new file mode 100644 index 0000000..163cb7f --- /dev/null +++ b/database/migrations/2026_06_08_162345_add_preferred_location_to_workers_table.php @@ -0,0 +1,30 @@ +string('preferred_location')->nullable()->after('area'); + } + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('workers', function (Blueprint $table) { + $table->dropColumn('preferred_location'); + }); + } +}; diff --git a/public/uploads/documents/1780921630_passport_passport.pdf b/public/uploads/documents/1780921630_passport_passport.pdf new file mode 100644 index 0000000..e69de29 diff --git a/tests/Feature/WorkerJourneyApiTest.php b/tests/Feature/WorkerJourneyApiTest.php index 8244ba9..234b537 100644 --- a/tests/Feature/WorkerJourneyApiTest.php +++ b/tests/Feature/WorkerJourneyApiTest.php @@ -416,36 +416,40 @@ public function test_register_with_new_api_fields() $fakePassport = UploadedFile::fake()->create('passport.pdf', 500, 'application/pdf'); $response = $this->postJson('/api/workers/register', [ - 'name' => 'John New Worker', - 'phone' => '+971501111112', - 'salary' => 2200.50, - 'password' => 'secret123', - 'passport_file' => $fakePassport, - 'language' => 'HI, SW', - 'nationality' => 'Kenya', - 'age' => 30, - 'experience' => '5 Years', - 'in_country' => 'true', - 'visa_status' => 'Tourist Visa', + 'name' => 'John New Worker', + 'phone' => '+971501111112', + 'salary' => 2200.50, + 'password' => 'secret123', + 'passport_file' => $fakePassport, + 'language' => 'HI', + 'nationality' => 'Kenya', + 'age' => 30, + 'experience' => '5 Years', + 'in_country' => 'true', + 'visa_status' => 'Tourist Visa', 'preferred_job_type' => 'full-time', - 'live_in_out' => 'Live-out (External housing)', - 'country' => 'UAE', - 'city' => 'Dubai', - 'area' => 'Marina', + 'gender' => 'male', + 'live_in_out' => 'live_out', + 'preferred_location' => 'Dubai Marina', + 'country' => 'UAE', + 'city' => 'Dubai', + 'area' => 'Marina', ]); $response->assertStatus(201); $this->assertDatabaseHas('workers', [ - 'name' => 'John New Worker', - 'phone' => '+971501111112', - 'in_country' => true, - 'visa_status' => 'Tourist Visa', + 'name' => 'John New Worker', + 'phone' => '+971501111112', + 'in_country' => true, + 'visa_status' => 'Tourist Visa', 'preferred_job_type' => 'full-time', - 'live_in_out' => 'Live-out (External housing)', - 'country' => 'UAE', - 'city' => 'Dubai', - 'area' => 'Marina', + 'gender' => 'male', + 'live_in_out' => 'live_out', + 'preferred_location' => 'Dubai Marina', + 'country' => 'UAE', + 'city' => 'Dubai', + 'area' => 'Marina', ]); } @@ -455,47 +459,51 @@ public function test_register_with_new_api_fields() public function test_update_profile_with_new_api_fields() { $worker = Worker::create([ - 'name' => 'Original Worker', - 'email' => 'orig@example.com', - 'phone' => '+971502222223', - 'language' => 'SW', - 'password' => bcrypt('password'), - 'nationality' => 'Kenya', - 'age' => 22, - 'salary' => 1200, + 'name' => 'Original Worker', + 'email' => 'orig@example.com', + 'phone' => '+971502222223', + 'language' => 'SW', + 'password' => bcrypt('password'), + 'nationality' => 'Kenya', + 'age' => 22, + 'salary' => 1200, 'availability' => 'Immediate', - 'experience' => 'None', - 'religion' => 'Christian', - 'bio' => 'New helper', - 'category_id' => $this->category->id, - 'verified' => false, - 'status' => 'active', - 'api_token' => 'bearer-update-token', + 'experience' => 'None', + 'religion' => 'Christian', + 'bio' => 'New helper', + 'category_id' => $this->category->id, + 'verified' => false, + 'status' => 'active', + 'api_token' => 'bearer-update-token', ]); $response = $this->withHeaders([ 'Authorization' => 'Bearer bearer-update-token', ])->postJson('/api/workers/profile/update', [ - 'in_country' => false, - 'visa_status' => null, + 'in_country' => false, + 'visa_status' => null, 'preferred_job_type' => 'part-time', - 'live_in_out' => 'Live-in (Stay with family)', - 'country' => 'UAE', - 'city' => 'Abu Dhabi', - 'area' => 'Khalifa City', + 'gender' => 'female', + 'live_in_out' => 'live_in', + 'preferred_location' => 'Abu Dhabi', + 'country' => 'UAE', + 'city' => 'Abu Dhabi', + 'area' => 'Khalifa City', ]); $response->assertStatus(200); $this->assertDatabaseHas('workers', [ - 'id' => $worker->id, - 'in_country' => false, - 'visa_status' => null, + 'id' => $worker->id, + 'in_country' => false, + 'visa_status' => null, 'preferred_job_type' => 'part-time', - 'live_in_out' => 'Live-in (Stay with family)', - 'country' => 'UAE', - 'city' => 'Abu Dhabi', - 'area' => 'Khalifa City', + 'gender' => 'female', + 'live_in_out' => 'live_in', + 'preferred_location' => 'Abu Dhabi', + 'country' => 'UAE', + 'city' => 'Abu Dhabi', + 'area' => 'Khalifa City', ]); } diff --git a/vite.config.js b/vite.config.js index 8ba613d..fa54835 100644 --- a/vite.config.js +++ b/vite.config.js @@ -23,7 +23,7 @@ export default defineConfig({ port: 5173, cors: true, hmr: { - host: '192.168.0.194', + host: '192.168.29.131', }, watch: { ignored: ['**/storage/framework/views/**'],