feat(menu): update logic sidebar menu
This commit is contained in:
parent
485a2f560e
commit
78c1afb0a8
@ -40,49 +40,37 @@
|
|||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
@php
|
@php
|
||||||
$headingOtorisasi = 0;
|
|
||||||
$headingMain = 0;
|
|
||||||
$headingMaster = 0;
|
|
||||||
$headingSystem = 0;
|
|
||||||
|
|
||||||
// Ensure $menus is defined and is an object
|
// Ensure $menus is defined and is an object
|
||||||
$menus = isset($menus) ? json_decode(json_encode($menus)) : new stdClass;
|
$menus = isset($menus) ? json_decode(json_encode($menus)) : new stdClass;
|
||||||
|
|
||||||
// Define the order of sections
|
// 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
|
@endphp
|
||||||
|
|
||||||
@foreach($sectionOrder as $section)
|
@foreach($sectionOrder as $section)
|
||||||
@if(!empty($menus->$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">
|
<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]">
|
<span class="menu-heading uppercase text-2sm font-semibold text-gray-500 pl-[10px] pr-[10px]">
|
||||||
Otorisator
|
{{ $sectionTitles[$section] }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</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)
|
@foreach($menus->$section as $menu)
|
||||||
@if(auth()->user()->hasRole($menu->roles))
|
@if(auth()->user()->hasRole($menu->roles))
|
||||||
@ -140,6 +128,7 @@
|
|||||||
@endif
|
@endif
|
||||||
@endforeach
|
@endforeach
|
||||||
@endif
|
@endif
|
||||||
|
@endif
|
||||||
@endforeach
|
@endforeach
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user