title: Foreach scope variable in laravel blade template
body: <p>ok I got this 'main' blade template with laravel Collection object called <code>$projects</code> and passed to the view</p>
  
  <p>'main.blade.php'</p>
  
  <pre><code>...
  &lt;div id="projects-list"&gt;
      &lt;?php $last_id = 0; ?&gt;
      @include('partials._project')
  &lt;/div&gt;
  
  &lt;div&gt;{{ $last_id }}&lt;/div&gt;
  ...
  </code></pre>
  
  <p>and 'partials._project.blade.php' template looks like this</p>
  
  <pre><code>@foreach($projects as $project)
  
      &lt;?php $last_id = $project-&gt;id ?&gt;
  
      &lt;a href="{{ action('ProjectController@index', $project-&gt;uri) }}"&gt;
          &lt;h4&gt;{{ $last_id }}&lt;/h4&gt; 
          &lt;img src="{{ $project-&gt;getProjectImage($project-&gt;poster) }}"&gt;
      &lt;/a&gt;
  @endforeach
  </code></pre>
  
  <p>The issue is that at this point <code>&lt;h4&gt;{{ $last_id }}&lt;/h4&gt;</code> i get the correct value of project ID (so the last block shows value of <code>6</code>)</p>
  
  <p>BUT in my main.blade.php at <code>&lt;div&gt;{{ $last_id }}&lt;/div&gt;</code> (after the loop is over) I get <code>0</code> (the initial value)</p>
  
  <p>I guess blade <code>@foreach</code> loop have no influance on outer scope's variables...
  Or am I wrong?</p>