title: Laravel Blade - Pass Data to layout without using it in every Public Function
body: <p>In my Laravel Blade Layout I created files for the header, navigation, footer, etc.
  Those Files have been <code>@include()</code>d into a layout file, which has a <code>yield('content')</code>.</p>
  
  <p>Now, I want to show for example a product in a view. The view however uses the <code>nav.blade.php</code>, which shows categories (loading from the db).</p>
  
  <p>When sending my <code>product</code> data to my view, I get an error, because the nav has no data about <code>categories</code>:</p>
  
  <pre><code>Undefined variable: categories
  </code></pre>
  
  <p>Is there a possibility to give the nav the data without sending it with every view?</p>
  
  <p>My <code>public function</code> for the product page currently looks like this:</p>
  
  <pre><code>$product = Product::findOrFail($id);
  return view('product.single')-&gt;with('product', $product);
  </code></pre>
  
  <p>In order to work it should also send this with it:</p>
  
  <pre><code>$categories = Category::with('subcategories.products.prices', 'subcategories.products.image')-&gt;get();
  </code></pre>
  
  <p>But i don't want to send that with every view.</p>