From d75434674f31ca22412fccc8f00fc7e4457ad9b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9Cmit=20Tun=C3=A7?= Date: Thu, 1 Jan 2026 00:12:46 +0300 Subject: [PATCH] Add Dynamic Menu Item Component: Introduced a new Blade component for front-end menu items, enhancing the navigation structure with support for mega menus and nested children. Updated the header template to utilize this component, improving modularity and localization for menu titles. --- .../components/front/menu-item.blade.php | 102 ++++ resources/views/partials/header.blade.php | 520 ++---------------- 2 files changed, 139 insertions(+), 483 deletions(-) create mode 100644 resources/views/components/front/menu-item.blade.php diff --git a/resources/views/components/front/menu-item.blade.php b/resources/views/components/front/menu-item.blade.php new file mode 100644 index 0000000..357faab --- /dev/null +++ b/resources/views/components/front/menu-item.blade.php @@ -0,0 +1,102 @@ +@props(['item']) + +@php + $hasChildren = $item->children->isNotEmpty(); + $isMegaMenu = $item->slug === 'urunlerimiz'; +@endphp + +@if($isMegaMenu) + +@else + +@endif + diff --git a/resources/views/partials/header.blade.php b/resources/views/partials/header.blade.php index 5bbea44..8a2038d 100644 --- a/resources/views/partials/header.blade.php +++ b/resources/views/partials/header.blade.php @@ -1,3 +1,27 @@ +@php +// Get menu items from Pages with nested children +$menuItems = \App\Models\Page::with(['children' => function ($query) { + $query->where('status', 'published') + ->where('show_in_menu', true) + ->orderBy('sort_order', 'asc') + ->orderBy('title', 'asc'); + }, 'children.children' => function ($query) { + $query->where('status', 'published') + ->where('show_in_menu', true) + ->orderBy('sort_order', 'asc') + ->orderBy('title', 'asc'); + }]) + ->whereNull('parent_id') + ->where('status', 'published') + ->where('show_in_menu', true) + ->orderBy('sort_order', 'asc') + ->orderBy('title', 'asc') + ->get(); + +$midPoint = ceil($menuItems->count() / 2); +$leftMenuItems = $menuItems->slice(0, $midPoint); +$rightMenuItems = $menuItems->slice($midPoint); +@endphp
-
\ No newline at end of file +