In Laravel Blade, the $loop variable is a special helper variable that is automatically made available inside @foreach and @for loops. It gives you useful information about the current state of the loop.
Common $loop Properties
Example Usage
<ul>
@foreach ($users as $user)
<li>
{{ $loop->iteration }}. {{ $user->name }}
@if ($loop->first)
- First user!
@endif
@if ($loop->last)
- Last user!
@endif
</li>
@endforeach
</ul>
Nested Loops Example
@foreach ($categories as $category)
<h2>{{ $category->name }}</h2>
<ul>
@foreach ($category->products as $product)
<li>
{{ $loop->parent->iteration }}.{{ $loop->iteration }} - {{ $product->name }}
</li>
@endforeach
</ul>
@endforeach
Source: Orkhan Alishov's notes