1 @php
2 $menus = [
3 'users.*' => 'users',
4 'roles.*' => 'roles',
5 ];
6 $selectedMenu = \Illuminate\Support\Arr::first($menus, fn($menu, $key) => request()->routeIs($key));
7@endphp
8
9<ul class="navbar-nav flex-column" x-data="{ selected: '{{$selectedMenu}}' }">
10 <li class="nav-item" @click="selected = 'users'">
11 <a class="nav-link collapsed" :class="{ 'top-active': selected === 'users' }"
12 href="#" data-toggle="collapse"
13 x-bind:aria-expanded="{ 'true': selected === 'users' }"
14 data-target="#submenu-users" aria-controls="submenu-users"
15 >
16 <i class="fas fa-fw fa-users"></i>Users
17 </a>
18 <div id="submenu-users" class="submenu collapse" :class="{ 'show': selected === 'users' }">
19 <ul class="nav flex-column">
20 <li class="nav-item">
21 <a class="nav-link {{ request()->routeIs('users.index') ? 'active' : '' }}" href="{{ route('users.index') }}">All Users</a>
22 </li>
23 </ul>
24 </div>
25 </li>
26</ul>