jeudi 29 juin 2017

Insert a div in random intervals Laravel collection

I have a laravel application which is an ecommerce store.

On my shop category which contains rows of products I'd like to randomly in between the products insert a div.

This div should be random throughout the page.

For example, I have the following (I've pruned the code to keep it clean):

@section('content')

    <div class="products"> 

    @foreach($page->products->chunk(6) as $chunk)

        <div class="group">

        @foreach($chunk as $product)
            <div class="category_product"> 

                <div class="category_product_info">
                    <h2>
                        <a href="">
                            
                        </a>
                    </h2>
                </div>

            </div>
        @endforeach

        </div>

    @endforeach

    </div>

@endsection

In the chunk of 6 is it possible to inject say a seventh element which would appear randomly on the row?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire