how to use loop in laravel code example
Example 1: how to write for loop in laravel blade
@for ($i = 0; $i < $max; $i++) //Where $max is whatever you need as break condition.
{{ $i }}
//This would print $i in a paragraph. You do whatever you need here.
@endfor
Example 2: laravel for loop
@for ($i = 0; $i < 10; $i++)
The current value is {{ $i }}
@endfor
@foreach ($users as $user)
This is user {{ $user->id }}
@endforeach
@forelse ($users as $user)
{{ $user->name }}
@empty
No users
@endforelse
@while (true)
I'm looping forever.
@endwhile