@if (!empty($metatags)) {{-- Basic Meta Tags --}} @if (!empty($metatags['keywords'])) @endif {{ $metatags['title'] ?? config('configrations.site_name') }} @if (!empty($metatags['time'])) @endif {{-- Security Headers --}} {{-- Canonical --}} @if (!empty($metatags['canonical'])) @else @php $currentUrl = url()->current(); $currentPath = request()->path(); // No need to modify - the URL should already be correct from the route @endphp @endif {{-- Favicon --}} {{-- Apple Touch Icons --}} {{-- Microsoft Tiles - Dynamic from Database --}} {{-- Microsoft Tiles --}} {{-- Open Graph --}} @php $ogUrl = url()->current(); $currentPath = request()->path(); // No need to modify - the URL should already be correct from the route @endphp {{-- Twitter --}} @if (!empty($metatags['twitter_site'])) @endif @if (!empty($metatags['twitter_creator'])) @endif {{-- Performance --}} {{-- Hreflang Tags --}} @php $locales = ['ar', 'en']; $currentPath = request()->path(); $pathWithoutLocale = preg_replace('/^(ar|en)\/?/', '', $currentPath); // Check if this is a blog page if (preg_match('/^blogs?\/(.+)$/', $pathWithoutLocale, $matches)) { $currentSlug = urldecode($matches[1]); $currentLocale = app()->getLocale(); // Try to find the blog using current locale first $blog = \App\Models\Blog::whereRaw("JSON_EXTRACT(slug, '$.{$currentLocale}') = ?", [$currentSlug])->first(); // If not found, try all locales if (!$blog) { foreach (['ar', 'en'] as $lang) { $blog = \App\Models\Blog::whereRaw("JSON_EXTRACT(slug, '$.{$lang}') = ?", [$currentSlug])->first(); if ($blog) { break; } } } // If not found with JSON_EXTRACT, try manual search if (!$blog) { $blogs = \App\Models\Blog::all(); foreach ($blogs as $b) { foreach (['ar', 'en'] as $lang) { $blogSlug = $b->getTranslation('slug', $lang); if ($blogSlug === $currentSlug) { $blog = $b; break 2; } } } } if ($blog) { $generatedUrls = []; // Generate URLs for each locale foreach ($locales as $locale) { $localizedUrl = $blog->getLocalizedUrl($locale); if ($localizedUrl) { $generatedUrls[$locale] = $localizedUrl; echo '' . "\n"; } } // Add x-default only if we have Arabic URL (default language) if (isset($generatedUrls['ar'])) { echo '' . "\n"; } } else { // Fallback to simple method if blog not found $path = $pathWithoutLocale ? '/' . $pathWithoutLocale : ''; foreach ($locales as $locale) { echo '' . "\n"; } // Add x-default pointing to Arabic echo '' . "\n"; } } elseif (preg_match('/^services\/(.+)$/', $pathWithoutLocale, $matches)) { // Handle services pages $currentSlug = urldecode($matches[1]); $currentLocale = app()->getLocale(); // Try to find the service using current locale first $service = \App\Models\Service::whereRaw("JSON_EXTRACT(slug, '$.{$currentLocale}') = ?", [ $currentSlug, ])->first(); // If not found, try all locales if (!$service) { foreach (['ar', 'en'] as $lang) { $service = \App\Models\Service::whereRaw("JSON_EXTRACT(slug, '$.{$lang}') = ?", [ $currentSlug, ])->first(); if ($service) { break; } } } // If not found with JSON_EXTRACT, try manual search if (!$service) { $services = \App\Models\Service::all(); foreach ($services as $s) { foreach (['ar', 'en'] as $lang) { $serviceSlug = $s->getTranslation('slug', $lang); if ($serviceSlug === $currentSlug) { $service = $s; break 2; } } } } if ($service) { $generatedUrls = []; // Generate URLs for each locale foreach ($locales as $locale) { $localizedUrl = $service->getLocalizedUrl($locale); if ($localizedUrl) { $generatedUrls[$locale] = $localizedUrl; echo '' . "\n"; } } // Add x-default only if we have Arabic URL (default language) if (isset($generatedUrls['ar'])) { echo '' . "\n"; } } else { // Fallback to simple method if service not found $path = $pathWithoutLocale ? '/' . $pathWithoutLocale : ''; foreach ($locales as $locale) { echo '' . "\n"; } // Add x-default pointing to Arabic echo '' . "\n"; } } elseif (preg_match('/^products\/(.+)$/', $pathWithoutLocale, $matches)) { // Handle products pages $currentSlug = urldecode($matches[1]); $currentLocale = app()->getLocale(); // Try to find the product using current locale first $product = \App\Models\Product::whereRaw("JSON_EXTRACT(slug, '$.{$currentLocale}') = ?", [ $currentSlug, ])->first(); // If not found, try all locales if (!$product) { foreach (['ar', 'en'] as $lang) { $product = \App\Models\Product::whereRaw("JSON_EXTRACT(slug, '$.{$lang}') = ?", [ $currentSlug, ])->first(); if ($product) { break; } } } // If not found with JSON_EXTRACT, try manual search if (!$product) { $products = \App\Models\Product::all(); foreach ($products as $p) { foreach (['ar', 'en'] as $lang) { $productSlug = $p->getTranslation('slug', $lang); if ($productSlug === $currentSlug) { $product = $p; break 2; } } } } if ($product) { $generatedUrls = []; // Generate URLs for each locale foreach ($locales as $locale) { $localizedUrl = $product->getLocalizedUrl($locale); if ($localizedUrl) { $generatedUrls[$locale] = $localizedUrl; echo '' . "\n"; } } // Add x-default only if we have Arabic URL (default language) if (isset($generatedUrls['ar'])) { echo '' . "\n"; } } else { // Fallback to simple method if product not found $path = $pathWithoutLocale ? '/' . $pathWithoutLocale : ''; foreach ($locales as $locale) { echo '' . "\n"; } // Add x-default pointing to Arabic echo '' . "\n"; } } else { // For non-blog pages, use the simple method $path = $pathWithoutLocale ? '/' . $pathWithoutLocale : ''; foreach ($locales as $locale) { echo '' . "\n"; } // Add x-default pointing to Arabic echo '' . "\n"; } @endphp {{-- Google Tag Manager --}} @if (config('settings.google_tag_manager_id')) @endif {{-- Google Analytics --}} @if (config('settings.google_analytics_id')) @endif @endif {{-- Schema JSON-LD --}} @if (!empty($schema)) @else {{-- Default WebPage Schema (safe encoding) --}} @php $schemaUrl = url()->current(); $currentPath = request()->path(); // No need to modify - the URL should already be correct from the route @endphp @endif {{-- Always include Organization/LocalBusiness Schema on all pages --}} {{-- FAQ Schema --}} @if (!empty($faq_schema)) @endif {{-- Breadcrumb Schema --}} @if (!empty($breadcrumb_schema)) @endif {{-- Google Tag Manager --}} @if (config('settings.google_tag_manager_id')) @endif {{-- Google Analytics --}} @if (config('settings.google_analytics_id')) @endif {{-- Organization/LocalBusiness Schema - Only show if no page-specific schema --}} @if (empty($schema)) @php // Build Organization/LocalBusiness Schema $defaultOrgSchema = [ '@context' => 'https://schema.org', '@type' => ['Organization', 'LocalBusiness', 'MedicalBusiness'], 'name' => config('configrations.site_name') ?? 'DHI Egypt', 'description' => config('configrations.site_description') ?? 'تقدم DHI خدمات متكاملة لزراعة الشعر واللحية باستخدام احدث التقنيات علي مستوي العالم', 'url' => url('/'), 'logo' => [ '@type' => 'ImageObject', 'url' => asset(\App\Helper\Path::AppLogo()), ], 'image' => asset(\App\Helper\Path::AppLogo()), 'priceRange' => '$$-$$$', ]; // Add sameAs only if social media URLs exist $sameAs = array_values( array_filter( [ config('settings.site_facebook'), config('settings.site_twitter'), config('settings.site_linkedin'), config('settings.site_instagram'), config('settings.site_youtube'), config('settings.site_tiktok'), ], function ($url) { return !empty($url) && $url !== '#' && filter_var($url, FILTER_VALIDATE_URL); }, ), ); if (!empty($sameAs)) { $defaultOrgSchema['sameAs'] = $sameAs; } // Add contactPoint only if phone exists $phone = config('settings.site_phone') ?? config('settings.site_whatsapp'); if (!empty($phone)) { $defaultOrgSchema['contactPoint'] = [ '@type' => 'ContactPoint', 'telephone' => $phone, 'contactType' => 'customer service', 'availableLanguage' => ['Arabic', 'English'], ]; } // Add all active addresses from SiteAddress model $siteAddresses = \App\Models\SiteAddress::where('status', true)->orderBy('order')->get(); if ($siteAddresses->isNotEmpty()) { $locations = []; $allPhones = []; foreach ($siteAddresses as $siteAddress) { if (!empty($siteAddress->address)) { // Create location with Place object (proper schema.org way) $locationSchema = [ '@type' => 'Place', 'name' => $siteAddress->title ?? null, 'address' => [ '@type' => 'PostalAddress', 'streetAddress' => $siteAddress->address, ], ]; // Add map link if exists (use map_link instead of map_url for direct Google Maps link) if (!empty($siteAddress->map_link)) { $locationSchema['hasMap'] = $siteAddress->map_link; } $locations[] = $locationSchema; // Collect phone numbers from all addresses if (!empty($siteAddress->phone) && strlen($siteAddress->phone) > 3) { $allPhones[] = $siteAddress->phone; } if (!empty($siteAddress->phone2) && strlen($siteAddress->phone2) > 3) { $allPhones[] = $siteAddress->phone2; } } } // Add locations to schema - if single location, add as object; if multiple, add as array if (count($locations) === 1) { $defaultOrgSchema['location'] = $locations[0]; } elseif (count($locations) > 1) { $defaultOrgSchema['location'] = $locations; } // Add all phone numbers if exist if (!empty($allPhones)) { $defaultOrgSchema['telephone'] = array_unique($allPhones); } } // Add areaServed only if exists $areaServed = config('settings.site_area_served'); if (!empty($areaServed)) { $defaultOrgSchema['areaServed'] = is_array($areaServed) ? $areaServed : explode(',', $areaServed); } // Add foundingDate only if exists $foundingDate = config('settings.site_founding_date'); if (!empty($foundingDate)) { $defaultOrgSchema['foundingDate'] = $foundingDate; } // Add founder only if exists $founder = config('settings.site_founder'); if (!empty($founder)) { $defaultOrgSchema['founder'] = [ '@type' => 'Person', 'name' => $founder, ]; } $defaultWebsiteSchema = [ '@context' => 'https://schema.org', '@type' => 'WebSite', 'name' => config('configrations.site_name') ?? 'ميبيكوم', 'url' => url('/'), 'potentialAction' => [ '@type' => 'SearchAction', 'target' => url('/') . '?q={search_term_string}', 'query-input' => 'required name=search_term_string', ], ]; @endphp {{-- Organization/LocalBusiness Schema --}} {{-- WebSite Schema --}} @endif {{-- Lazy Loading Images --}} {{-- Web Vitals --}}