jeudi 1 mars 2018

laravel Prevent foreach loop from repeating same results

Am doing a loop where a product can have many sizes so I display the name of the product and its 1st size and the name of the same product again with its 2nd size but anytime i try, it repeats both sizes on both product names. For example:

I want Product 1 = small, Product 1 = medium but in this case it displays...

Product 1 = small medium, Product 2= small medium. How do I solve this. Below is my blade;

 @foreach ($productProductOptions as $productProductOption)
    <tr>
       <td></td>

       <td></td>

       <td>

         @foreach($productProductOption->product->options as $productOptions)

            

        @endforeach 
 @endforeach 

Below is my controller code which am passing to the view;

   $productProductOptions = ProductProductOption::all();

This is the picture of the table am displaying the items inside...https://pasteboard.co/H9Sym4b.png



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2oH1YI1
via IFTTT

Aucun commentaire:

Enregistrer un commentaire