brarear's avatar

Blade template foreach loop split every 15 loops in html list

I have item that is result from model is 60 items and I want to display it in html list. 15 items per list. That mean I will have 4 lists for this result. This is my code in view.

@foreach($items as $item)
    @if($loop->first or $loop->iteration % 15 == 0)
        <ul>
    @endif
    <li>
        <a href="#">{!! $item->name !!}</a>
    </li>
    @if($loop->last == true or $loop->iteration % 15 == 0)
        </ul>
    @endif
@endforeach

It's look correct but why show only one list.

0 likes
2 replies

Please or to participate in this conversation.