jeudi 20 octobre 2016

How to insert a div for every nth object in laravel

I have a foreach loop where I need to insert a div every nth object.

 @if(count($articles))

    @foreach($articles as $article)

        @if(this is the nth object)
            <div class="row margin-b-2">
        @endif
            <div class="col-sm-4">
                <a style="background-color: " href=""></a>
            </div>

        @if(this is the nth object)
           </div>
        @endif
    @endforeach
 @endif

this is the bare bones of what I am trying to do.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire