title: Laravel: Include view with controller logic
body: <p>I come from the symfony (v1) world, where we had two types of partial rendering: partials, which loaded the same as:</p>
  
  <pre><code>@include('some.view')
  </code></pre>
  
  <p>and controllers, which would act the exact same way but would be ran with some controller logic behind hit. So, calling the same as above would first go to the matching some.view controller, and operate with the logic it had.</p>
  
  <p>I'm trying to do the same with Laravel. Basically, I have this:</p>
  
  <pre><code>@foreach($array as $thing)
    @include('controller.like.view', array('thing' =&gt; $thing))
  @endforeach
  </code></pre>
  
  <p>... and I'd like my included view to run something like this (this is just an example, the actual code is a lot more complicated, otherwise I'd just write it with an if clause in Blade):</p>
  
  <pre><code>...
  if ($thing%2) {
        return 'a';
  }
  
  return 'b';
  </code></pre>
  
  <p>... so that only 'a' or 'b' would be printed in my loop. What's the best way to achieve this without having a bunch of PHP code in a Blade template?</p>