title: Multi-level menu in laravel 5.1 - loops
body: <p>I am a little bit new with laravel 5.1 framework. Last couple of days I create my database (insert, update, delete) for dynamic menu I want to create. I connect with default layout in which i put menu. From route code looks like this.</p>
  
  <pre><code>View::composer('layouts.default',function($view){
      $menus = Menu::where('parent_id',0)-&gt;orderBy('order')-&gt;get();
      $submenus = Menu::where('parent_id','!=',0)-&gt;get();
      $view-&gt;with(compact('menus','submenus'));
  });
  </code></pre>
  
  <p>In main menu are items with parent_id = 0. Submenu items have parent_id = id, and soo on.</p>
  
  <p>I want to display correct but when I hover main menu items that dont have items, css block appear, becouse i didnt make good if condition. Is there any way to do this?</p>
  
  <p>Code in view look like this.</p>
  
  <pre><code>@foreach($menus as $menu)
                      &lt;li class="dropdown {!! (Request::is('typography') || Request::is('advancedfeatures') || Request::is('grid') ? 'active' : '') !!}"&gt;&lt;a href="#" class="dropdown-toggle" data-toggle="dropdown"&gt; {!! $menu-&gt;title !!}&lt;/a&gt;
                          &lt;ul class="dropdown-menu" role="menu"&gt;
                          @foreach($submenus as $submenu)
                                  @if($submenu-&gt;parent_id === $menu-&gt;id)
                                  &lt;li&gt;&lt;a href="{{ URL::to('typography') }}"&gt;{!! $submenu-&gt;title !!}&lt;/a&gt;
                                      @foreach($submenus as $smenu)
                                              @if($smenu-&gt;parent_id === $submenu-&gt;id)
                                                  &lt;ul class="dropdown-submenu" role="menu"&gt;
                                                      &lt;li&gt;&lt;a href="{{ URL::to('typography') }}"&gt;{!! $smenu-&gt;title !!}&lt;/a&gt;
                                                      &lt;/li&gt;
                                                  &lt;/ul&gt;
                                              @endif
                                      @endforeach
                                  &lt;/li&gt;
                              @endif
                              @endforeach
                          &lt;/ul&gt;
                      &lt;/li&gt;
                      @endforeach
  </code></pre>
  
  <p>One more question is how to take only one value from <strong>Menu model</strong> for example <strong>id</strong> that can be used to point only one submenu.</p>
  
  <p>Best regards!</p>