title: Laravel foreach variable loop scope
body: <p>When I use Laravel blade file foreach loop, the variable is accessible after the foreach loop, whereas the scope of the variable should be only within the loop</p>
  
  <pre><code>@foreach($user-&gt;referral as $ref)
    &lt;tr&gt;
      &lt;td&gt;{{ $ref-&gt;referral_amount }}&lt;/td&gt;
      &lt;td&gt;{{ $ref-&gt;status }}&lt;/td&gt;
    &lt;/tr&gt;
  @endforeach
  </code></pre>
  
  <p>$ref: This variable accessible outside endforeach loop after @endforeach</p>