title: Dynamic data in Laravel/Blade for subset of views
body: <p>I have a model for a productgroup that links to the products via an ID. When the user clicks on a productgroup, I want to show a menu on the left side where the user can click on a link to edit</p>
  
  <ol>
  <li><p>the productgroup and</p></li>
  <li><p>the products in the productgroup.</p></li>
  </ol>
  
  <p>There are also other pages in the same menu. For example a page about "managing the homepage", resulting in the fact that not every page (view) is able to deliver a productgroup or list of single products.</p>
  
  <p>I have this menu structure:</p>
  
  <ul>
  <li>Edit homepage</li>
  <li>Productgroup
  
  <ul>
  <li>Edit brand information</li>
  <li>Edit seo text</li>
  <li>Edit warranty info</li>
  </ul></li>
  <li>Product 1
  
  <ul>
  <li>Edit Basic info product 1</li>
  <li>Edit Facts product 1</li>
  </ul></li>
  <li>Product 2
  
  <ul>
  <li>Edit Basic info product 1</li>
  <li>Edit Facts product 1</li>
  </ul></li>
  </ul>
  
  <p>What I want to achieve is that for some views I pass the corresponding <strong>"products"</strong> to the view. That way I can create a list in the menu. However, some controllers don't have that info (e.g. the edit homepage controller), so I can't pass it to the view. When the controller does not pass the info to the view, the view gives an error.</p>
  
  <p>I have a very basic setup of views:</p>
  
  <ul>
  <li><em>app.blade.php</em> includes some general views</li>
  <li><em>app.blade.php</em> yields the specific views that are loaded by the controller</li>
  </ul>
  
  <p>In <em>app.blade.php</em> I pass, for example, some values to the menu:</p>
  
  <pre><code>@include('backoffice/menu', array('ProductGroup'=&gt;$vars['groupinfo'], 'Products'=&gt;$vars['productinfo']))
  </code></pre>
  
  <p>What is the best way to build up the dynamic menu?</p>