@php $defaultPricings = function_exists('marketplaceDefaultCountryPricings') ? marketplaceDefaultCountryPricings() : []; $allCountrySections = function_exists('marketplaceCountrySections') ? marketplaceCountrySections() : []; // Build a lookup of existing defaults by name $existingKeys = collect($defaultPricings)->pluck('name')->map(fn($n) => strtolower(trim($n)))->all(); // Add any other countries from countrySections that aren't already in the top 30 $extraCountries = []; foreach ($allCountrySections as $sectionTitle => $cList) { foreach ($cList as $c) { $cName = trim($c['name'] ?? ''); if ($cName !== '' && !in_array(strtolower($cName), $existingKeys, true)) { $existingKeys[] = strtolower($cName); $extraCountries[] = [ 'name' => $cName, 'code' => strtolower(str_replace('fi fi-', '', $c['flag_class'] ?? 'gb')), 'flag_class' => $c['flag_class'] ?? 'fi fi-gb', 'amount' => 8.00, 'enabled' => false, ]; } } } $combinedCountries = array_merge($defaultPricings, $extraCountries); // If editing an existing service, determine selected country & price $currentService = $service ?? null; $currentCountry = old('country', $currentService?->country ?? ''); $currentServicePrice = (float) ($currentService?->price ?? 0); @endphp