I had the exact same issue.
@foreach($topics as $topic)
{{ $topic->title }}
@endforeach
{{ $topic->id }} // <- this should fail but $topic remains set
I later found out that this is not a Blade issue but an issue with PHP itself. If you have a PHP foreach loop the variable for a single item, of the array you are looping trough, will be available after the loop and it will be set to the last item of the array.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community