@if($location_style == 'autocomplete')
@php
$location_name = "";
$list_json = [];
$location_id = request()->get('location');
$traverse = function ($locations, $prefix = '') use (&$traverse, &$list_json, &$location_name, $location_id) {
foreach ($locations as $location) {
$translate = $location->translateOrOrigin(app()->getLocale());
if ($location_id == $location->id) {
$location_name = $translate->name;
}
$list_json[] = [
'id' => $location->id,
'title' => $prefix.' '.$translate->name,
];
$traverse($location->children, $prefix.'-');
}
};
$traverse($list_locations);
@endphp
@else
@endif