@php $primaryBranch = ($siteData?->branches ?? [])[0] ?? null; $footerAbout = $siteData?->getTranslation('short_description', app()->getLocale(), false) ?: $siteData?->getTranslation('short_description', 'en', false) ?: ''; $contactPhone = $siteData?->phone ?: ($primaryBranch['phone'] ?? ''); $contactEmail = $siteData?->email ?: ($primaryBranch['email'] ?? ''); $contactAddress = $siteData?->getTranslation('address', app()->getLocale(), false) ?: $siteData?->getTranslation('address', 'en', false) ?: ($primaryBranch['address'] ?? ''); $whatsAppPhone = $siteData?->whatsapp ?: preg_replace('/\D+/', '', (string) $contactPhone); // Phones: main number, then each branch's from Main Data > Contact > Branches. Addresses: the // branches' own when they have any (the main address usually repeats the first branch), else the main one. $footerBranches = collect($siteData?->branches ?? []); $footerPhones = collect([$contactPhone])->merge($footerBranches->pluck('phone'))->filter()->map(fn ($v) => trim((string) $v))->unique()->take(3); $branchAddresses = $footerBranches->pluck('address')->filter()->map(fn ($v) => trim((string) $v))->unique(); $footerAddresses = ($branchAddresses->isNotEmpty() ? $branchAddresses : collect([$contactAddress])->filter())->take(3); $footerLinks = [ ['route' => 'home', 'label' => trans('site.nav.home')], ['route' => 'about', 'label' => trans('site.nav.about')], ['route' => 'services', 'label' => trans('site.nav.services')], ['route' => 'clinic.search', 'label' => trans('site.nav.doctors')], ['route' => 'before-after', 'label' => trans('site.nav.before_after')], ['route' => 'blog.index', 'label' => trans('site.nav.blog')], ['route' => 'contact', 'label' => trans('site.nav.contact')], ]; @endphp @if ($whatsAppPhone) @endif