Organize the dashboard menu a bit better and include both form submission view pages under the same menu item

This commit is contained in:
Kevin MacMartin 2018-04-17 18:52:44 -04:00
parent aafd2d96a2
commit 94c31b1ff4
4 changed files with 28 additions and 26 deletions

View file

@ -10,7 +10,21 @@ class DashboardMenu
* @return array
*/
public static $menu = [
[ 'Contact', 'contact' ],
[ 'Subscriptions', 'subscriptions' ]
[
'title' => 'Submissions',
'submenu' => [
[
'title' => 'Contact',
'type' => 'view',
'model' => 'contact'
],
[
'title' => 'Subscriptions',
'type' => 'view',
'model' => 'subscriptions'
]
]
]
];
}

View file

@ -3,24 +3,24 @@
@section('dashboard-body')
<div class="list-group menu-list">
@foreach(App\Models\DashboardMenu::$menu as $menu_item)
@if(is_array($menu_item[1]))
@foreach($menu_item[1] as $submenu_item)
@if(array_key_exists('submenu', $menu_item))
@foreach($menu_item['submenu'] as $submenu_item)
<li class="list-group-item">
{{ $menu_item[0] }}: {{ $submenu_item[0] }}
{{ $menu_item['title'] }}: {{ $submenu_item['title'] }}
<a
class="list-group-item-link"
href="{{ url('/dashboard/' . $submenu_item[1]) }}">
href="{{ url('/dashboard/' . $submenu_item['type'] . '/' . $submenu_item['model']) }}">
</a>
</li>
@endforeach
@else
<li class="list-group-item">
{{ $menu_item[0] }}
{{ $menu_item['title'] }}
<a
class="list-group-item-link"
href="{{ url('/dashboard/' . $menu_item[1]) }}">
href="{{ url('/dashboard/' . $menu_item['type'] . '/' . $menu_item['model']) }}">
</a>
</li>
@endif

View file

@ -1,12 +0,0 @@
@set('menu', [
[ 'Contact', 'contact' ],
[ 'Subscriptions', 'subscriptions' ]
])
@foreach($menu as $menu_item)
<li class="{{ $menu_class }}">
<a href="{{ url('/dashboard/' . $menu_item[1]) }}">
{{ $menu_item[0] }}
</a>
</li>
@endforeach

View file

@ -19,22 +19,22 @@
@endif
@else
@foreach(App\Models\DashboardMenu::$menu as $menu_item)
@if(is_array($menu_item[1]))
@if(array_key_exists('submenu', $menu_item))
<li class="nav-item dropdown">
<a id="menu-dropdown" class="nav-link dropdown-toggle" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{{ $menu_item[0] }} <span class="caret"></span>
{{ $menu_item['title'] }} <span class="caret"></span>
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="menu-dropdown">
@foreach($menu_item[1] as $submenu_item)
<a class="dropdown-item" href="{{ url('/dashboard/' . $submenu_item[1]) }}">{{ $submenu_item[0] }}</a>
@foreach($menu_item['submenu'] as $submenu_item)
<a class="dropdown-item" href="{{ url('/dashboard/' . $submenu_item['type'] . '/' . $submenu_item['model']) }}">{{ $submenu_item['title'] }}</a>
@endforeach
</div>
</li>
@else
<li class="nav-item">
<a class="nav-link {{ $current_page == $menu_item[1] ? 'active' : '' }}" href="{{ url('/dashboard/' . $menu_item[1]) }}">
{{ $menu_item[0] }}
<a class="nav-link {{ $current_page == $menu_item['model'] ? 'active' : '' }}" href="{{ url('/dashboard/' . $menu_item['type'] . '/' . $menu_item['model']) }}">
{{ $menu_item['title'] }}
</a>
</li>
@endif