title: Laravel Eager Load with dynamic constraints
body: <p>Can anybody please help me to understand why the following code is working</p>
  
  <pre><code>$x = $widget-&gt;objGallery-&gt;galleryItems()-&gt;with(array('captions' =&gt; function($query){ $query-&gt;where('locale', 'IT' );}))-&gt;get() ;
  </code></pre>
  
  <p>but when I am using a dynamic value</p>
  
  <pre><code>$id='11';
  $x = $widget-&gt;objGallery-&gt;galleryItems()-&gt;with(array('captions' =&gt; function($query){ $query-&gt;where('locale', $id );}))-&gt;get() ;
  </code></pre>
  
  <p>is saying</p>
  
  <blockquote>
    <p>Method Illuminate\View\View::__toString() must not throw an exception</p>
  </blockquote>