M
M
miniven2016-03-21 12:53:04
HTML
miniven, 2016-03-21 12:53:04

How to make multiple blocks using foreach?

How to display 6 elements per block using foreach in php. Those. it is necessary that there were n blocks with 6 elements from the database in each?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrzej Wielski, 2016-03-21
@miniven

Blade:

@foreach($items->chunk(6) as $items_chunk)
<ul>
    @foreach($items_chunk as $item)
        <li>{{ $item->name }}</li>
    @endforeach
</ul>
@endforeach

Done with the chunk() method on the collection

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question