@props([ 'name' => 'phone', 'countryCodeName' => 'country_code', 'value' => '', 'countryCode' => null, 'defaultCountryIso' => null, 'label' => null, 'placeholder' => null, 'required' => true, 'autofocus' => false, 'disabled' => false, 'readonly' => false, 'id' => null, 'wrapperClass' => '', ]) @php use App\Support\PhoneNumber; $componentId = $id ?? 'phone-input-'.uniqid(); $label = $label ?? __('lang.phone'); $placeholder = $placeholder ?? '00XXXXXXXX'; $searchPlaceholder = __('lang.search'); $rawValue = old($name, $value); $parsed = PhoneNumber::parse($rawValue); $dialFromOld = old($countryCodeName); $resolvedDial = $dialFromOld ?: ($countryCode ?? $parsed['country_code']); $resolvedIso = PhoneNumber::isoFromDialCode($resolvedDial) ?? ($defaultCountryIso ?? PhoneNumber::isoFromRequest()); if ($dialFromOld && old($name) !== null) { $nationalValue = ltrim(preg_replace('/\D+/', '', (string) old($name)) ?? '', '0'); } elseif (old($name) !== null) { $nationalValue = PhoneNumber::parse(old($name))['national']; } else { $nationalValue = $parsed['national']; } $countriesJson = json_encode(PhoneNumber::localizedCountries(), JSON_UNESCAPED_UNICODE); @endphp
@if ($label) @endif
{{ $resolvedDial }} @if (! $disabled && ! $readonly) @endif
@if (! $disabled && ! $readonly)
@endif
@error($name)
{{ $message }}
@enderror @error($countryCodeName)
{{ $message }}
@enderror
@once @push('styles') @endpush @push('scripts') @endpush @endonce