I come from the symfony (v1) world, where we had two types of partial rendering: partials, which loaded the same as:
@include('some.view')
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.
I'm trying to do the same with Laravel. Basically, I have this:
@foreach($array as $thing)
@include('controller.like.view', array('thing' => $thing))
@endforeach
... 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):
...
if ($thing%2) {
return 'a';
}
return 'b';
... 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?