diff --git a/resources/views/layouts/sidebar.blade.php b/resources/views/layouts/sidebar.blade.php index 2465da1..a1cf3bd 100644 --- a/resources/views/layouts/sidebar.blade.php +++ b/resources/views/layouts/sidebar.blade.php @@ -39,95 +39,106 @@ @php - $headingSystem = 0; + $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']; @endphp - @php $menus = json_decode(json_encode($menus)); @endphp - @foreach($menus as $key => $value) - @foreach($value as $menu) - @if($key=='main') - @if($headingMain == 0) - - @php $headingMain = 1; @endphp - @endif - @elseif($key=='master') - @if($headingMaster == 0) - - @php $headingMaster = 1; @endphp - @endif - @elseif($key=='system') - @if($headingSystem == 0) - - @php $headingSystem = 1; @endphp - @endif + + @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 - @if(auth()->user()->hasRole($menu->roles)) - @if(isset($menu->sub)) -