title: Laravel: Drop down options pulled from database in Master blade template are not showing on other pages
body: <p>I have created a menu in master blade template in Laravel and have extended that to the other pages. That menu has a dropdown, with several options, that get fetched from the database. While, this works on the master template. It throws the same error on rest of the pages.</p>
  <p>How should I fix this?</p>
  <p>Here's the error:</p>
  <pre><code>&quot;ErrorException
  Undefined variable: types (View: /Applications/MAMP/htdocs/bootstrap/laravel-project.app/resources/views/layouts/master.blade.php)&quot;
  </code></pre>
  <p>Here's the web.php code:</p>
  <pre><code>Route::get('/master', [MenuController::class, 'show'])
      -&gt;name('master.show');
  </code></pre>
  <p>Controller.php</p>
  <pre><code>    &lt;?php
  
  namespace App\Http\Controllers;
  
  use Illuminate\Http\Request;
  use App\Models\DoshaType;
  
  class MenuController extends Controller
  {
      public function show(){
             
          $types = DoshaType::all();
      
          return view('layouts/master', compact('types'));
          
      }
  
  }
  </code></pre>
  <p>view code</p>
  <pre><code>&lt;!doctype html&gt;
  
  &lt;html&gt;
  
      &lt;head&gt;
          
          
      &lt;/head&gt;
  
  
      &lt;body&gt;
  
          &lt;div class = &quot;container-fluid&quot;&gt;
              
              &lt;div class = &quot;row&quot;&gt;
                  &lt;div class = &quot;col-2 mt-2&quot;&gt;
                      &lt;div class = &quot;logo&quot;&gt;
                          &lt;img src = &quot;./images/logo.png&quot; id= &quot;logo&quot;&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
                  
                  &lt;div class = &quot;col-10&quot;&gt;
  
                      &lt;nav class=&quot;navbar navbar-expand-lg navbar-dark bg-primary mt-2&quot;&gt;
                          
  
                          &lt;button class=&quot;navbar-toggler&quot; type=&quot;button&quot; data-toggle=&quot;collapse&quot; data-target=&quot;#navbarNavDropdown&quot; aria-controls=&quot;navbarNavDropdown&quot; aria-expanded=&quot;false&quot; aria-label=&quot;Toggle navigation&quot;&gt;
                              &lt;span class=&quot;navbar-toggler-icon&quot;&gt;&lt;/span&gt;
                          &lt;/button&gt;
                          
                          &lt;div class=&quot;collapse navbar-collapse&quot; id=&quot;navbarNavDropdown&quot;&gt;
                              &lt;ul class=&quot;navbar-nav&quot;&gt;
                              &lt;li class=&quot;nav-item active&quot;&gt;
                                  &lt;a class=&quot;nav-link&quot; href=&quot;home&quot;&gt;Home &lt;span class=&quot;sr-only&quot;&gt;(current)&lt;/span&gt;&lt;/a&gt;
                              &lt;/li&gt;
                              &lt;li class=&quot;nav-item&quot;&gt;
                                  &lt;a class=&quot;nav-link&quot; href=&quot;#&quot;&gt;A&lt;/a&gt;
                              &lt;/li&gt;
                              &lt;li class=&quot;nav-item&quot;&gt;
                                  &lt;a class=&quot;nav-link&quot; href=&quot;#&quot;&gt;Y&lt;/a&gt;
                              &lt;/li&gt;
                              &lt;li class=&quot;nav-item dropdown&quot;&gt;
                                  &lt;a class=&quot;nav-link dropdown-toggle&quot; href=&quot;#&quot; id=&quot;navbarDropdownMenuLink&quot; data-toggle=&quot;dropdown&quot; aria-haspopup=&quot;true&quot; aria-expanded=&quot;false&quot;&gt;
                                  
                                  M
                                  
                                  &lt;/a&gt;
                                  
                            &lt;div class=&quot;dropdown-menu&quot; aria-labelledby=&quot;navbarDropdownMenuLink&quot;&gt;
                                      @foreach ($types as $type) 
                                             
                                          &lt;a class=&quot;dropdown-item&quot; href=&quot;#&quot;&gt;{{ $type-&gt;dosha }} &lt;/a&gt;
                                      @endforeach
                                  &lt;/div&gt;
  </code></pre>