Laravel8 – View loaded by @include in loop always keeps a value of the first loop

  laravel, php

When I do things like this:

<loader.blade.php>
@foreach($items as $item)
  @include('loaded', ['item' => $item])
@endforeach
<loaded.blade.php>
<div>
  {{ $item->name }}
</div>

$item in loaded.blade.php always has the same value, meaning the value of the first $item in loop.

Is this normal? If so, how can I avoid it. If that is not normal, what might be causing this problem?

Source: Laravel

Leave a Reply