title: Laravel: Failed to send variable (Undefined Variable)
body: <p>I'm new at Laravel. and i got a little problem with view.</p>
  
  <p>here is my controller </p>
  
  <pre><code>public function main_menu()
  {   
      $mainmenus = DB::table('main_menus')-&gt;get();
  
      $subs = $mainmenus;
      foreach ($subs as $key =&gt; $value) 
      {
          $subs[$key] = DB::table('sub_menus')
                          -&gt;where('parent_id', '=' , $value-&gt;main_id)
                          -&gt;get();
      }
  
      $products = DB::table('sub_menus')-&gt;get();
      foreach ($products as $key =&gt; $value) {
          $products[$key] = DB::table('products')
                                  -&gt; where('product_parent', '=', $value-&gt;sub_id)
                                  -&gt;get();
      }
  
      $data = array("mainmenus" =&gt; $mainmenus,
              "submenus" =&gt; $subs,
              "productmenus" =&gt; $products);
  
      return View::make('layouts/nav', $data);
  
  }
  </code></pre>
  
  <p>and here is my layouts/nav.blade.php</p>
  
  <pre><code> @extends('layouts_index')
  
   @section('nav')
   &lt;div class="nav"&gt;
   &lt;nav class="navbar"&gt;
      &lt;ul id="menu"&gt;
  
          &lt;li class="active"&gt;&lt;a href="index" class="drop"&gt;&lt;i class="icon-home icon-small"&gt;  &lt;/i&gt;Home&lt;/a&gt;&lt;/li&gt;
  
          @foreach ($mainmenus as $key=&gt;$mainmenu) 
              &lt;li&gt;
                  &lt;a href="menu/{{ $mainmenu-&gt;main_id }}" class="drop"&gt;
                  &lt;i class="icon-{{ $mainmenu-&gt;main_icon }} icon-small"&gt;&lt;/i&gt;{{ $mainmenu-&gt;main_title_id }}&lt;/a&gt;
                  @if( $mainmenu-&gt;main_desc_id != "")
                      &lt;div class="dropdown_3columns"&gt;
                          &lt;div class="col_4"&gt;
                              &lt;h3&gt;&lt;i class="icon-{{ $mainmenu-&gt;main_icon }} icon-large"&gt;&lt;/i&gt;{{ $mainmenu-&gt;main_title_id }}&lt;/h3&gt;
                              &lt;h4&gt;{{ $mainmenu-&gt;main_desc_id }}&lt;/h4&gt;  
                          &lt;/div&gt;
                          @foreach ($submenus[$key] as $key=&gt;$submenu) 
                              &lt;div class="col_1"&gt;
                                  &lt;a href="" &gt;&lt;h5&gt;&lt;i class="icon-small icon-bookmark"&gt;&lt;/i&gt;{{ $submenu-&gt;sub_title_id }}&lt;/h5&gt;&lt;/a&gt;   
  
                                  &lt;ul&gt;
                                  @foreach ($productmenus[$key] as $productmenu)
                                      &lt;li&gt;
                                          &lt;a href="" &gt;&lt;i class="icon-small icon-th-large"&gt;&lt;/i&gt;{{ $productmenu-&gt;product_title_id }}&lt;/a&gt;
                                      &lt;/li&gt;   
                                  @endforeach
  
                                  &lt;/ul&gt;
                              &lt;/div&gt;
  
                          @endforeach
  
                      &lt;/div&gt;
                  @endif
              &lt;/li&gt;
          @endforeach
          &lt;li class="last"&gt;&lt;a href="#" class="drop "&gt;&lt;i class="icon-pencil icon-small"&gt;&lt;/i&gt;Tentang Kami&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt; 
    &lt;/nav&gt;
   &lt;/div&gt;
  
  @stop
  </code></pre>
  
  <p>my routes: </p>
  
  <pre><code>  Route::get('/', 'ShowsController@index');
  </code></pre>
  
  <p>when i try to run the index.blade.php it says:
  Undefined variable: mainmenus (View: C:\xampp\htdocs\mestika\app\views\layouts\nav.blade.php) (View: C:\xampp\htdocs\mestika\app\views\layouts\nav.blade.php) (View: C:\xampp\htdocs\mestika\app\views\layouts\nav.blade.php)</p>
  
  <p>what i want to do is i want to show main_menu at every view pages. i've tried changed view::make to view::share. but no luck. is there anything i miss at here?</p>