@php
$contactNumber = $address->contact_number;
// Find which country code matches the start of the contact number
$countryCode = '';
$localNumber = '';
foreach ($flagMap as $code => $flag) {
if (str_starts_with($contactNumber, $code)) {
$countryCode = $code;
$localNumber = substr($contactNumber, strlen($code));
break;
}
}
// If no match, fallback
if (!$countryCode) {
$countryCode = '+41'; // Default country code (or empty string)
$localNumber = $contactNumber;
}
$localNumber = ltrim($localNumber, '0'); // Remove leading zero if any
@endphp