Blade has @foreach, @for, @while and @forelse, whose @empty branch handles an empty list; @continue and @break accept a condition. Every @foreach gets a $loop object:
@foreach ($products as $p)
@continue($p->stock === 0)
{{ $loop->iteration }}/{{ $loop->count }} {{ $p->title }}{{ $loop->first ? ' (first)' : '' }}
@foreach ($p->tags as $tag)
- {{ $tag }} [depth {{ $loop->depth }}, parent #{{ $loop->parent->iteration }}]
@endforeach
@endforeachOutput
1/3 The Pragmatic Programmer (first) - craft [depth 2, parent #1] - career [depth 2, parent #1] 2/3 Designing Data-Intensive Applications - databases [depth 2, parent #2]
The sold-out book was skipped, yet count is still 3: it counts the collection. $loop also has index, remaining, last, even and odd; for a generator or LazyCollection, which Blade never counts, count, remaining and last are null. @each('partials.row', $products, 'product') renders a partial per item, without the parent's variables.