1// For
2@for ($i = 0; $i < max_value; $i++)
3 //your code
4@endfor
5//Foreach
6@foreach ($items as $item)
7 //your code
8@endforeach
1<div>
2 @for ($i = 0; $i < $max; $i++) //Where $max is whatever you need as break condition.
3 <p>{{ $i }}</p> //This would print $i in a paragraph. You do whatever you need here.
4 @endfor
5</div>
1@for ($i = 0; $i < 10; $i++)
2 The current value is {{ $i }}
3@endfor
4
5@foreach ($users as $user)
6 <p>This is user {{ $user->id }}</p>
7@endforeach
8
9@forelse ($users as $user)
10 <li>{{ $user->name }}</li>
11@empty
12 <p>No users</p>
13@endforelse
14
15@while (true)
16 <p>I'm looping forever.</p>
17@endwhile
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>