Friday, March 31, 2017

showing each single image of products in laravel

I have double tables one for products and one for files, files table have multi images related to the one product.

I want to show only one image for each product not all of them.

I make this code but it's back with the for example 3 times with the first image!

@foreach($lastProducts as $key => $lastProduct)
@if($key == 1)
<div class="bl-thumb">
<img src="">
</div>
@endif
@endforeach

I need to show the first image at my page and other pages show the second and third image for the product.

And here's my view which want to show all images on it :

<div class="slim-scroll">
    <div class="item active">
        <a href="" title="" data-lg-img="/website/images/" class="pic"><img src="/website/images/" alt="" class="img-responsive" /></a>
    </div>
    <div class="item">
        <a href="javascript:void(0)" title="" data-lg-img="/website/images/" class="pic"><img src="/website/images/" alt="" class="img-responsive" /></a>
    </div>
    <div class="item">
        <a href="javascript:void(0)" title="" data-lg-img="/website/images/" class="pic"><img src="/website/images/" alt="" class="img-responsive" /></a>
    </div>
    <div class="item">
        <a href="javascript:void(0)" title="" data-lg-img="/website/images/" class="pic"><img src="/website/images/" alt="" class="img-responsive" /></a>
    </div>
</div>

It's showing me something like that without the foreach

enter image description here enter image description here



via Dina Shaldoum

Advertisement