title: Laravel display dynamic menu items on layout template
body: <p>I have defined a Category model and table that I'm filling through the backend of my Laravel application. I want to display the categories as menu items.</p>
  
  <p>In my controller, I have something like</p>
  
  <pre><code>public function index()
  {
      $categories = Category::all();
      return view('layouts.app', ['categories' =&gt; $categories]);
  }
  </code></pre>
  
  <p>So the idea is that I can loop in the layouts.app template over these categories.</p>
  
  <pre><code> @foreach($categories as $category)
         &lt;li&gt;&lt;a href="..." class="user-icon"&gt;{{ $category-&gt;name}} &lt;/a&gt;&lt;/li&gt;
   @endforeach
  </code></pre>
  
  <p>How can I make sure that my app displays these catagories on all pages (that use the layouts.app template). Normally one could create a route entry but how to do this for the layouts.app template?</p>