Compare commits
No commits in common. "93b3018a0abf22a0cd49108307eae76da2cc9a21" and "6071c6144006cf522cfcfdf772b4faa59a7d9576" have entirely different histories.
93b3018a0a
...
6071c61440
@ -1246,7 +1246,7 @@ private function cleanVisaData(array $visaDataInput): array
|
|||||||
$rawEntryPermitNo = $visaDataInput['entry_permit_no'] ?? $visaDataInput['file_number'] ?? $visaDataInput['id_number'] ?? $visaDataInput['number'] ?? null;
|
$rawEntryPermitNo = $visaDataInput['entry_permit_no'] ?? $visaDataInput['file_number'] ?? $visaDataInput['id_number'] ?? $visaDataInput['number'] ?? null;
|
||||||
$rawIssueDate = $visaDataInput['issue_date'] ?? null;
|
$rawIssueDate = $visaDataInput['issue_date'] ?? null;
|
||||||
$rawValidUntil = $visaDataInput['valid_until'] ?? $visaDataInput['expiry_date'] ?? null;
|
$rawValidUntil = $visaDataInput['valid_until'] ?? $visaDataInput['expiry_date'] ?? null;
|
||||||
$rawUidNo = $visaDataInput['uid_no'] ?? $visaDataInput['id_number'] ?? null;
|
$rawUidNo = $visaDataInput['uid_no'] ?? null;
|
||||||
$rawFullName = $visaDataInput['full_name'] ?? $visaDataInput['name'] ?? null;
|
$rawFullName = $visaDataInput['full_name'] ?? $visaDataInput['name'] ?? null;
|
||||||
$rawNationality = $visaDataInput['nationality'] ?? null;
|
$rawNationality = $visaDataInput['nationality'] ?? null;
|
||||||
$rawPlaceOfBirth = $visaDataInput['place_of_birth'] ?? null;
|
$rawPlaceOfBirth = $visaDataInput['place_of_birth'] ?? null;
|
||||||
|
|||||||
@ -768,7 +768,7 @@ private function cleanVisaData(array $visaDataInput): array
|
|||||||
$rawEntryPermitNo = $visaDataInput['entry_permit_no'] ?? $visaDataInput['file_number'] ?? $visaDataInput['id_number'] ?? $visaDataInput['number'] ?? null;
|
$rawEntryPermitNo = $visaDataInput['entry_permit_no'] ?? $visaDataInput['file_number'] ?? $visaDataInput['id_number'] ?? $visaDataInput['number'] ?? null;
|
||||||
$rawIssueDate = $visaDataInput['issue_date'] ?? null;
|
$rawIssueDate = $visaDataInput['issue_date'] ?? null;
|
||||||
$rawValidUntil = $visaDataInput['valid_until'] ?? $visaDataInput['expiry_date'] ?? null;
|
$rawValidUntil = $visaDataInput['valid_until'] ?? $visaDataInput['expiry_date'] ?? null;
|
||||||
$rawUidNo = $visaDataInput['uid_no'] ?? $visaDataInput['id_number'] ?? null;
|
$rawUidNo = $visaDataInput['uid_no'] ?? null;
|
||||||
$rawFullName = $visaDataInput['full_name'] ?? $visaDataInput['name'] ?? null;
|
$rawFullName = $visaDataInput['full_name'] ?? $visaDataInput['name'] ?? null;
|
||||||
$rawNationality = $visaDataInput['nationality'] ?? null;
|
$rawNationality = $visaDataInput['nationality'] ?? null;
|
||||||
$rawPlaceOfBirth = $visaDataInput['place_of_birth'] ?? null;
|
$rawPlaceOfBirth = $visaDataInput['place_of_birth'] ?? null;
|
||||||
|
|||||||
@ -1,89 +0,0 @@
|
|||||||
<?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
|
|
||||||
{
|
|
||||||
$visaDocuments = \DB::table('worker_documents')->where('type', 'visa')->get();
|
|
||||||
foreach ($visaDocuments as $doc) {
|
|
||||||
$ocrData = json_decode($doc->ocr_data, true);
|
|
||||||
if (is_array($ocrData)) {
|
|
||||||
$cleaned = $this->cleanVisaData($ocrData);
|
|
||||||
\DB::table('worker_documents')->where('id', $doc->id)->update([
|
|
||||||
'ocr_data' => json_encode($cleaned)
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*/
|
|
||||||
public function down(): void
|
|
||||||
{
|
|
||||||
// Cleaning up or reverting structure is not strictly necessary or possible
|
|
||||||
// since we map legacy fields to modern ones.
|
|
||||||
}
|
|
||||||
|
|
||||||
private function cleanVisaData(array $visaDataInput): array
|
|
||||||
{
|
|
||||||
$rawVisaType = $visaDataInput['visa_type'] ?? null;
|
|
||||||
$rawEntryPermitNo = $visaDataInput['entry_permit_no'] ?? $visaDataInput['file_number'] ?? $visaDataInput['id_number'] ?? $visaDataInput['number'] ?? null;
|
|
||||||
$rawIssueDate = $visaDataInput['issue_date'] ?? null;
|
|
||||||
$rawValidUntil = $visaDataInput['valid_until'] ?? $visaDataInput['expiry_date'] ?? null;
|
|
||||||
$rawUidNo = $visaDataInput['uid_no'] ?? $visaDataInput['id_number'] ?? null;
|
|
||||||
$rawFullName = $visaDataInput['full_name'] ?? $visaDataInput['name'] ?? null;
|
|
||||||
$rawNationality = $visaDataInput['nationality'] ?? null;
|
|
||||||
$rawPlaceOfBirth = $visaDataInput['place_of_birth'] ?? null;
|
|
||||||
$rawDateOfBirth = $visaDataInput['date_of_birth'] ?? $visaDataInput['dob'] ?? null;
|
|
||||||
$rawPassportNo = $visaDataInput['passport_no'] ?? $visaDataInput['passport_number'] ?? null;
|
|
||||||
$rawProfession = $visaDataInput['profession'] ?? null;
|
|
||||||
$rawSponsorName = $visaDataInput['sponsor_name'] ?? null;
|
|
||||||
$rawOcrAccuracy = $visaDataInput['ocr_accuracy'] ?? null;
|
|
||||||
|
|
||||||
// Clean sponsor
|
|
||||||
$sponsorData = $visaDataInput['sponsor'] ?? [];
|
|
||||||
if (is_string($sponsorData)) {
|
|
||||||
$sponsorNameFromObj = $sponsorData;
|
|
||||||
$sponsorAddress = '';
|
|
||||||
$sponsorPhone = '';
|
|
||||||
} else {
|
|
||||||
$sponsorNameFromObj = $sponsorData['name'] ?? $sponsorData['sponsor_name'] ?? $sponsorData['full_name'] ?? '';
|
|
||||||
$sponsorAddress = $sponsorData['address'] ?? '';
|
|
||||||
$sponsorPhone = $sponsorData['phone'] ?? $sponsorData['mobile'] ?? $sponsorData['mobile_number'] ?? $sponsorData['phone_number'] ?? '';
|
|
||||||
}
|
|
||||||
if (empty($rawSponsorName)) {
|
|
||||||
$rawSponsorName = $sponsorNameFromObj;
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
|
||||||
'document_type' => 'uae_visa',
|
|
||||||
'country' => 'United Arab Emirates',
|
|
||||||
'visa_type' => $rawVisaType ?: 'ENTRY PERMIT',
|
|
||||||
'entry_permit_no' => $rawEntryPermitNo ?: '',
|
|
||||||
'issue_date' => $rawIssueDate ?: '',
|
|
||||||
'valid_until' => $rawValidUntil ?: '',
|
|
||||||
'uid_no' => $rawUidNo ?: '',
|
|
||||||
'full_name' => $rawFullName ?: '',
|
|
||||||
'nationality' => $rawNationality ?: '',
|
|
||||||
'place_of_birth' => $rawPlaceOfBirth ?: '',
|
|
||||||
'date_of_birth' => $rawDateOfBirth ?: '',
|
|
||||||
'passport_no' => $rawPassportNo ?: '',
|
|
||||||
'profession' => $rawProfession ?: '',
|
|
||||||
'sponsor_name' => $rawSponsorName ?: '',
|
|
||||||
'ocr_accuracy' => $rawOcrAccuracy !== null ? (int)$rawOcrAccuracy : 99,
|
|
||||||
'sponsor' => [
|
|
||||||
'name' => $sponsorNameFromObj ?: '',
|
|
||||||
'address' => $sponsorAddress ?: '',
|
|
||||||
'phone' => $sponsorPhone ?: '',
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@ -1102,85 +1102,92 @@
|
|||||||
},
|
},
|
||||||
"visa": {
|
"visa": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"description": "Standardized UAE Visa metadata.",
|
"description": "Optional JSON object containing extracted visa details.",
|
||||||
"properties": {
|
"properties": {
|
||||||
"document_type": {
|
"accompanied_by": {
|
||||||
"type": "string",
|
"type": "string"
|
||||||
"example": "uae_visa"
|
|
||||||
},
|
},
|
||||||
"country": {
|
"country": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "United Arab Emirates"
|
"example": "United Arab Emirates"
|
||||||
},
|
},
|
||||||
"visa_type": {
|
"date_of_birth": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "ENTRY PERMIT"
|
"example": "25-JUN-1999"
|
||||||
|
},
|
||||||
|
"document_type": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "uae_visa"
|
||||||
},
|
},
|
||||||
"entry_permit_no": {
|
"entry_permit_no": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "77003098 / 2019 / 204"
|
"example": "77003098 / 2019 / 204"
|
||||||
},
|
},
|
||||||
"issue_date": {
|
"expiry_date": {
|
||||||
"type": "string",
|
|
||||||
"example": "2022-02-16"
|
|
||||||
},
|
|
||||||
"valid_until": {
|
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "2024-02-15"
|
"example": "2024-02-15"
|
||||||
},
|
},
|
||||||
"uid_no": {
|
"file_number": {
|
||||||
"type": "string",
|
"type": "string"
|
||||||
"example": "207404887"
|
|
||||||
},
|
},
|
||||||
"full_name": {
|
"full_name": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "Mr.MUHAMMAD NADEEM RASHEED"
|
"example": "Mr.MUHAMMAD NADEEM RASHEED"
|
||||||
},
|
},
|
||||||
|
"id_number": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"issue_date": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "2022-02-16"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"nationality": {
|
"nationality": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "PAKISTAN"
|
"example": "PAKISTAN"
|
||||||
},
|
},
|
||||||
"place_of_birth": {
|
"ocr_accuracy": {
|
||||||
"type": "string",
|
"type": "number",
|
||||||
"example": "SIALKOT PAK"
|
"format": "float",
|
||||||
},
|
"example": 99
|
||||||
"date_of_birth": {
|
|
||||||
"type": "string",
|
|
||||||
"example": "25-JUN-1999"
|
|
||||||
},
|
},
|
||||||
"passport_no": {
|
"passport_no": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "EN9458281"
|
"example": "EN9458281"
|
||||||
},
|
},
|
||||||
|
"passport_number": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"place_of_birth": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "SIALKOT PAK"
|
||||||
|
},
|
||||||
|
"place_of_issue": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"profession": {
|
"profession": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "SALES REPRESENTATIVE"
|
"example": "SALES REPRESENTATIVE"
|
||||||
},
|
},
|
||||||
"sponsor_name": {
|
|
||||||
"type": "string",
|
|
||||||
"example": "Sponsor Name"
|
|
||||||
},
|
|
||||||
"ocr_accuracy": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "float",
|
|
||||||
"example": 97.4
|
|
||||||
},
|
|
||||||
"sponsor": {
|
"sponsor": {
|
||||||
"type": "object",
|
"type": "string"
|
||||||
"properties": {
|
},
|
||||||
"name": {
|
"sponsor_name": {
|
||||||
"type": "string",
|
"type": "string"
|
||||||
"example": "Sponsor Name"
|
},
|
||||||
},
|
"uid_no": {
|
||||||
"address": {
|
"type": "string",
|
||||||
"type": "string",
|
"example": "207404887"
|
||||||
"example": "Dubai Marina, Dubai"
|
},
|
||||||
},
|
"valid_until": {
|
||||||
"phone": {
|
"type": "string",
|
||||||
"type": "string",
|
"example": "04-MAR-2019"
|
||||||
"example": "2977725"
|
},
|
||||||
}
|
"visa_type": {
|
||||||
}
|
"type": "string",
|
||||||
|
"example": "ENTRY PERMIT"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -6641,108 +6648,82 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "uploads/licenses/1234567890_emirates_id.pdf"
|
"example": "uploads/licenses/1234567890_emirates_id.pdf"
|
||||||
},
|
},
|
||||||
"license_expiry": {
|
|
||||||
"type": "string",
|
|
||||||
"nullable": true,
|
|
||||||
"example": "2026-05-03"
|
|
||||||
},
|
|
||||||
"validity": {
|
|
||||||
"type": "string",
|
|
||||||
"example": "Valid"
|
|
||||||
},
|
|
||||||
"joined_at": {
|
|
||||||
"type": "string",
|
|
||||||
"format": "date-time"
|
|
||||||
},
|
|
||||||
"fcm_token": {
|
"fcm_token": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "fcm_token_example"
|
"example": "fcm_token_example"
|
||||||
},
|
},
|
||||||
"license": {
|
"document_type": {
|
||||||
"type": "object",
|
"type": "string",
|
||||||
"properties": {
|
"example": "dubai_commercial_license"
|
||||||
"license_number": {
|
},
|
||||||
"type": "string",
|
"country": {
|
||||||
"example": "828302"
|
"type": "string",
|
||||||
},
|
"example": "United Arab Emirates"
|
||||||
"organization_name": {
|
},
|
||||||
"type": "string",
|
"authority": {
|
||||||
"example": "MSJ INTERNATIONAL TECHNICAL SERVICES L.L.C"
|
"type": "string",
|
||||||
},
|
"example": "Dubai Economy and Tourism"
|
||||||
"expiry_date": {
|
},
|
||||||
"type": "string",
|
"license_no": {
|
||||||
"example": "2026-05-03"
|
"type": "string",
|
||||||
},
|
"example": "828302"
|
||||||
"document_type": {
|
},
|
||||||
"type": "string",
|
"company_name": {
|
||||||
"example": "dubai_commercial_license"
|
"type": "string",
|
||||||
},
|
"example": "MSJ INTERNATIONAL TECHNICAL SERVICES L.L.C"
|
||||||
"country": {
|
},
|
||||||
"type": "string",
|
"business_name": {
|
||||||
"example": "United Arab Emirates"
|
"type": "string",
|
||||||
},
|
"example": "MSJ INTERNATIONAL TECHNICAL SERVICES L.L.C"
|
||||||
"authority": {
|
},
|
||||||
"type": "string",
|
"license_category": {
|
||||||
"example": "Dubai Economy and Tourism"
|
"type": "string",
|
||||||
},
|
"example": "Dep. of Economic Development"
|
||||||
"license_no": {
|
},
|
||||||
"type": "string",
|
"legal_type": {
|
||||||
"example": "828302"
|
"type": "string",
|
||||||
},
|
"example": "Limited Liability Company Single Owner(LLC- - SO)"
|
||||||
"company_name": {
|
},
|
||||||
"type": "string",
|
"issue_date": {
|
||||||
"example": "MSJ INTERNATIONAL TECHNICAL SERVICES L.L.C"
|
"type": "string",
|
||||||
},
|
"example": "06/03/2019"
|
||||||
"business_name": {
|
},
|
||||||
"type": "string",
|
"expiry_date": {
|
||||||
"example": "MSJ INTERNATIONAL TECHNICAL SERVICES L.L.C"
|
"type": "string",
|
||||||
},
|
"example": "05/03/2026"
|
||||||
"license_category": {
|
},
|
||||||
"type": "string",
|
"main_license_no": {
|
||||||
"example": "Dep. of Economic Development"
|
"type": "string",
|
||||||
},
|
"example": "828302"
|
||||||
"legal_type": {
|
},
|
||||||
"type": "string",
|
"register_no": {
|
||||||
"example": "Limited Liability Company Single Owner(LLC- - SO)"
|
"type": "string",
|
||||||
},
|
"example": "1656486"
|
||||||
"issue_date": {
|
},
|
||||||
"type": "string",
|
"dcci_no": {
|
||||||
"example": "06/03/2019"
|
"type": "string",
|
||||||
},
|
"example": "317412"
|
||||||
"main_license_no": {
|
},
|
||||||
"type": "string",
|
"members": {
|
||||||
"example": "828302"
|
"type": "array",
|
||||||
},
|
"items": {
|
||||||
"register_no": {
|
"type": "object",
|
||||||
"type": "string",
|
"properties": {
|
||||||
"example": "1656486"
|
"person_no": {
|
||||||
},
|
"type": "string",
|
||||||
"dcci_no": {
|
"example": "752967"
|
||||||
"type": "string",
|
},
|
||||||
"example": "317412"
|
"name": {
|
||||||
},
|
"type": "string",
|
||||||
"members": {
|
"example": "Lo lo wallus issued in"
|
||||||
"type": "array",
|
},
|
||||||
"items": {
|
"nationality": {
|
||||||
"type": "object",
|
"type": "string",
|
||||||
"properties": {
|
"example": "India"
|
||||||
"person_no": {
|
},
|
||||||
"type": "string",
|
"role": {
|
||||||
"example": "752967"
|
"type": "string",
|
||||||
},
|
"example": "Shares Owner Who"
|
||||||
"name": {
|
|
||||||
"type": "string",
|
|
||||||
"example": "Lo lo wallus issued in"
|
|
||||||
},
|
|
||||||
"nationality": {
|
|
||||||
"type": "string",
|
|
||||||
"example": "India"
|
|
||||||
},
|
|
||||||
"role": {
|
|
||||||
"type": "string",
|
|
||||||
"example": "Shares Owner Who"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -676,8 +676,7 @@ export default function Show({ worker }) {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="p-6">
|
{visaDoc.ocr_data ? (() => {
|
||||||
{visaDoc.ocr_data ? (() => {
|
|
||||||
const sponsorObj = visaDoc.ocr_data?.sponsor;
|
const sponsorObj = visaDoc.ocr_data?.sponsor;
|
||||||
const isSponsorObj = sponsorObj && typeof sponsorObj === 'object' && !Array.isArray(sponsorObj);
|
const isSponsorObj = sponsorObj && typeof sponsorObj === 'object' && !Array.isArray(sponsorObj);
|
||||||
const sponsorName = isSponsorObj
|
const sponsorName = isSponsorObj
|
||||||
|
|||||||
@ -531,13 +531,9 @@ public function test_register_passport_and_visa_with_direct_json_payload()
|
|||||||
|
|
||||||
$visaDoc = \App\Models\WorkerDocument::where('worker_id', $workerId)->where('type', 'visa')->first();
|
$visaDoc = \App\Models\WorkerDocument::where('worker_id', $workerId)->where('type', 'visa')->first();
|
||||||
$this->assertNotNull($visaDoc->ocr_data);
|
$this->assertNotNull($visaDoc->ocr_data);
|
||||||
$this->assertEquals('784198839607839', $visaDoc->ocr_data['uid_no']);
|
$this->assertEquals('784198839607839', $visaDoc->ocr_data['id_number']);
|
||||||
$this->assertEquals('CLEANER', $visaDoc->ocr_data['profession']);
|
$this->assertEquals('CLEANER', $visaDoc->ocr_data['profession']);
|
||||||
$this->assertEquals([
|
$this->assertEquals('Sponsor Name', $visaDoc->ocr_data['sponsor']);
|
||||||
'name' => 'Sponsor Name',
|
|
||||||
'address' => '',
|
|
||||||
'phone' => '',
|
|
||||||
], $visaDoc->ocr_data['sponsor']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -634,7 +630,7 @@ public function test_register_visa_with_full_ocr_fields()
|
|||||||
$this->assertEquals('uae_visa', $visaDoc->ocr_data['document_type']);
|
$this->assertEquals('uae_visa', $visaDoc->ocr_data['document_type']);
|
||||||
$this->assertEquals('ENTRY PERMIT', $visaDoc->ocr_data['visa_type']);
|
$this->assertEquals('ENTRY PERMIT', $visaDoc->ocr_data['visa_type']);
|
||||||
$this->assertEquals('Mr.MUHAMMAD NADEEM RASHEED', $visaDoc->ocr_data['full_name']);
|
$this->assertEquals('Mr.MUHAMMAD NADEEM RASHEED', $visaDoc->ocr_data['full_name']);
|
||||||
$this->assertEquals(97.4, $visaDoc->ocr_accuracy);
|
$this->assertEquals(97.4, $visaDoc->ocr_data['ocr_accuracy']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user