feat(menu): update logic sidebar menu

This commit is contained in:
Daeng Deni Mardaeni 2025-03-20 14:13:42 +07:00
parent 485a2f560e
commit 78c1afb0a8

View File

@ -40,49 +40,37 @@
</div>
</a>
@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
$hasVisibleItems = false;
foreach($menus->$section as $menu) {
if(auth()->user()->hasRole($menu->roles)) {
$hasVisibleItems = true;
break;
}
}
@endphp
@if($hasVisibleItems)
<div class="menu-item pt-2.25 pb-px">
<span class="menu-heading uppercase text-2sm font-semibold text-gray-500 pl-[10px] pr-[10px]">
Otorisator
{{ $sectionTitles[$section] }}
</span>
</div>
@php $headingOtorisasi = 1; @endphp
@elseif($section == 'main' && $headingMain == 0)
<div class="menu-item pt-2.25 pb-px">
<span class="menu-heading uppercase text-2sm font-semibold text-gray-500 pl-[10px] pr-[10px]">
Apps
</span>
</div>
@php $headingMain = 1; @endphp
@elseif($section == 'master' && $headingMaster == 0)
<div class="menu-item pt-2.25 pb-px">
<span class="menu-heading uppercase text-2sm font-semibold text-gray-500 pl-[10px] pr-[10px]">
Master Data
</span>
</div>
@php $headingMaster = 1; @endphp
@elseif($section == 'system' && $headingSystem == 0)
<div class="menu-item pt-2.25 pb-px">
<span class="menu-heading uppercase text-2sm font-semibold text-gray-500 pl-[10px] pr-[10px]">
Systems
</span>
</div>
@php $headingSystem = 1; @endphp
@endif
@foreach($menus->$section as $menu)
@if(auth()->user()->hasRole($menu->roles))
@ -140,6 +128,7 @@
@endif
@endforeach
@endif
@endif
@endforeach
</div>
</div>