From 78c1afb0a8d854a51c9f2221a3e5d931e517c74a Mon Sep 17 00:00:00 2001 From: Daeng Deni Mardaeni Date: Thu, 20 Mar 2025 14:13:42 +0700 Subject: [PATCH] feat(menu): update logic sidebar menu --- resources/views/layouts/sidebar.blade.php | 165 ++++++++++------------ 1 file changed, 77 insertions(+), 88 deletions(-) diff --git a/resources/views/layouts/sidebar.blade.php b/resources/views/layouts/sidebar.blade.php index b5fd388..549015b 100644 --- a/resources/views/layouts/sidebar.blade.php +++ b/resources/views/layouts/sidebar.blade.php @@ -40,105 +40,94 @@ @php - $headingOtorisasi = 0; - $headingMain = 0; - $headingMaster = 0; - $headingSystem = 0; - // Ensure $menus is defined and is an object $menus = isset($menus) ? json_decode(json_encode($menus)) : new stdClass; // Define the order of sections - $sectionOrder = ['main','otorisator', 'master', 'system']; + $sectionOrder = ['main', 'otorisator', 'master', 'system']; + $sectionTitles = [ + 'main' => 'Apps', + 'otorisator' => 'Otorisator', + 'master' => 'Master Data', + 'system' => 'Systems' + ]; @endphp @foreach($sectionOrder as $section) @if(!empty($menus->$section)) - @if($section == 'otorisator' && $headingOtorisasi == 0) - - @php $headingOtorisasi = 1; @endphp - @elseif($section == 'main' && $headingMain == 0) - - @php $headingMain = 1; @endphp - @elseif($section == 'master' && $headingMaster == 0) - - @php $headingMaster = 1; @endphp - @elseif($section == 'system' && $headingSystem == 0) - - @php $headingSystem = 1; @endphp - @endif + @php + $hasVisibleItems = false; + foreach($menus->$section as $menu) { + if(auth()->user()->hasRole($menu->roles)) { + $hasVisibleItems = true; + break; + } + } + @endphp - @foreach($menus->$section as $menu) - @if(auth()->user()->hasRole($menu->roles)) - @if(isset($menu->sub)) -