title: Laravel blade template specific code
body: <p>Currently we are using the Laravel framework on several projects, but one issue we keep running into which i don't like is the following issue:</p>
  
  <p>Lets say you have a Homepage and a Content page</p>
  
  <p>HomepageController has all Homepage specific php code 
  ContentpageController has all Content specific php code</p>
  
  <p>we have an app.blade.php that does</p>
  
  <pre><code>@yield('page')
  </code></pre>
  
  <p>HomepageController calls the view homepage.blade.php containing </p>
  
  <pre><code>@extends('app')
  
  @section('page')
       Some HTML part
       @include('parts.top_5')
  @endsection
  </code></pre>
  
  <p>ContentController calls the view content.blade.php containing </p>
  
  <pre><code>@extends('app')
  
  @section('page')
       Some different HTML part
       @include('parts.top_5')
  @endsection
  </code></pre>
  
  <p>Here you can see both pages include parts.top_5, the top 5 needs some specific variables to output the top5. Now the issue is we are currently copying the code for the top5 variables in both controllers or in grouped middleware but is there a better solution to generate some blade specific variables when the part is included? So a bit like running a controller function on loading the blade template?</p>
  
  <p>I have been searching the internet but can't seem to find anyone with the same question. Hopefully someone can help me on this mindbreaking issue!</p>