@php $settingsService = app(\App\Services\SettingsService::class); $siteName = $settingsService->get('site_name', config('app.name')); $siteDescription = $settingsService->get('site_description', 'A powerful content management system built with Laravel'); $contactEmail = $settingsService->get('contact_email', config('mail.from.address')); $contactPhone = $settingsService->get('contact_phone', '+123 (4567) 890'); $contactPhones = collect(preg_split('/\s*(?:\/|,|;|\r\n|\r|\n)\s*/', (string) $contactPhone)) ->map(fn ($phone) => trim($phone)) ->filter() ->values(); $logoSetting = $settingsService->get('primary_logo') ?: $settingsService->get('logo_url'); $logoLight = $logoSetting ? asset('storage/' . $logoSetting) : asset('frontend/images/logo/ndarama-logo.svg'); try { $latestNews = \Illuminate\Support\Facades\Cache::remember( 'frontend:footer-latest-news', now()->addMinutes(10), fn () => \App\Models\News::published() ->latest('published_at') ->take(2) ->get(['id', 'title', 'slug', 'featured_image', 'published_at']) ); } catch (\Throwable $exception) { $latestNews = collect(); } try { $footerServices = \Illuminate\Support\Facades\Cache::remember( 'frontend:footer-services', now()->addMinutes(10), fn () => \App\Models\Service::active() ->orderBy('sort_order') ->orderBy('name') ->take(5) ->get(['id', 'name', 'slug']) ); } catch (\Throwable $exception) { $footerServices = collect(); } $footerMenuJson = $settingsService->get('footer_menu'); $configuredFooterMenu = is_string($footerMenuJson) ? json_decode($footerMenuJson, true) : $footerMenuJson; $footerMenu = collect(is_array($configuredFooterMenu) ? $configuredFooterMenu : []) ->filter(fn ($item) => is_array($item) && ($item['enabled'] ?? true) && !empty($item['label']) && !empty($item['href'])) ->sortBy(fn ($item) => (int) ($item['sort_order'] ?? 0)) ->map(function ($item) { $href = trim((string) $item['href']); return [ 'label' => trim((string) $item['label']), 'href' => preg_match('/^(?:https?:|mailto:|tel:)/i', $href) ? $href : url('/' . ltrim($href, '/')), ]; }) ->values(); if ($footerMenu->isEmpty()) { $footerMenu = collect([ ['label' => 'About Us', 'href' => route('frontend.about')], ['label' => 'Pricing', 'href' => route('frontend.pricing')], ['label' => 'Our Team', 'href' => route('frontend.teams.index')], ['label' => 'Latest News', 'href' => route('frontend.news.index')], ['label' => 'Events', 'href' => route('frontend.events.index')], ['label' => 'Contact Us', 'href' => route('frontend.contact')], ['label' => 'Careers', 'href' => route('frontend.vacancies.index')], ]); } elseif (!$footerMenu->contains(fn ($item) => rtrim((string) $item['href'], '/') === rtrim(route('frontend.events.index'), '/'))) { $footerMenu->push(['label' => 'Events', 'href' => route('frontend.events.index')]); } $socialLinks = [ 'facebook_url' => ['icon' => 'fab fa-facebook-f', 'label' => 'Facebook'], 'twitter_url' => ['icon' => 'fab fa-x-twitter', 'label' => 'X'], 'linkedin_url' => ['icon' => 'fab fa-linkedin-in', 'label' => 'LinkedIn'], 'instagram_url' => ['icon' => 'fab fa-instagram', 'label' => 'Instagram'], ]; $footerSocialLinks = collect($socialLinks) ->map(function ($social, $settingKey) use ($settingsService) { $url = trim((string) $settingsService->get($settingKey, '')); return $url === '' ? null : [ 'url' => $url, 'icon' => $social['icon'], 'label' => $social['label'], ]; }) ->filter() ->values(); @endphp