I am using ceil() method to count how many <div class="item"> block it should create. Each .item can only have 4 img.
I am having problem figuring out how to allow 4 img only and then create next .item block via loop.
@foreach(range(1, ceil($product->photos->count()/4)) as $section)
<div class="item">
<div class="row">
@foreach($product->photos as $photo)
<img src="{{$photo->photo_url}}" alt="" data-target="#carousel" data-slide-to="{{$loop->index}}" class="galleryItem">
@endforeach
</div>
</div>
@endforeach
You can use chunk method in foreach like
@foreach($posts->chunk(2) as $tempPosts)
<div class = "row">
@foreach($tempPosts as $post)
/* your code*/
@endforeach
</div>
@endforeach