CrestRoad/laravel/resources/views/partials/register-location-scripts.b...

28 lines
1.0 KiB
PHP

@php
$registerLocationCountries = [];
foreach ([
resource_path('data/countriesAndStates.json'),
public_path('assets/data/countriesAndStates.json'),
storage_path('app/geo/countriesAndStates.json'),
public_path('data/countriesAndStates.json'),
] as $countriesPath) {
if (is_readable($countriesPath)) {
$decoded = json_decode(file_get_contents($countriesPath), true);
if (is_array($decoded) && count($decoded) > 0 && array_keys($decoded) !== range(0, count($decoded) - 1)) {
$registerLocationCountries = $decoded;
break;
}
}
}
@endphp
<script src="{{ asset('assets/js/register-location-countries-data.js') }}"></script>
@if(count($registerLocationCountries) > 0)
<script>
window.REGISTER_LOCATION_COUNTRIES = @json($registerLocationCountries);
</script>
@endif
<script>
window.REGISTER_LOCATION_CITIES_URL = @json(url('/geo/cities'));
</script>
<script src="{{ asset('assets/js/register-location-dropdowns.js') }}"></script>