first item in foreach in laravel code example
Example 1: how get the first item in foreach in laravel
@foreach($items as $item)
@if ($loop->first) First Item: @endif
{{ $item->program_name }}
@endforeach
Example 2: laravel foreach first
@foreach ($users as $user)
@if ($loop->first)
This is the first iteration.
@endif
@if ($loop->last)
This is the last iteration.
@endif
This is user {{ $user->id }}
@endforeach