1<ul>
2@foreach ($pages as $page)
3 <li>{{ $loop->iteration }}: {{ $page->title }}
4 @if ($page->hasChildren())
5 <ul>
6 @foreach ($page->children() as $child)
7 <li>{{ $loop->parent->iteration }}.{{ $loop->iteration }}:
8 {{ $child->title }}</li>
9 @endforeach
10 </ul>
11 @endif
12 </li>
13@endforeach
14</ul>
1$loop->index Returns a 0-based current loop iteration; 0 would mean the first iteration
2$loop->iteration Returns a 1-based current loop iteration; 1 would mean the first iteration
3$loop->remaining Number of iterations remaining in the loop; if there are a total of 10 iterations and the current iteration is 3, it would return 7
4$loop->count Returns the total number of iterations or the total number of items in the array
5$loop->first Returns true if it is the first iteration or item in the loop else returns false.
6$loop->last Returns true if it is the last iteration or item in the loop else return false.
7$loop->depth Returns the depth or nesting level of the current loop; returns 2 if it is a loop within a loop and 3 if it is nested one level more
8$loop->parentIf this loop is nested within another @foreach loop, parent returns the parent’s loop