samedi 14 mars 2020

How to use data form different collection to show in single table row having products and product options in different collection in blade file

So i am using laravel 5.4 and fetching Orders from orders table and each order has multiple products which is stored in ordered_products table with orders_id as foreign Key both table, Now some products have option variables like size and color stored in another table ordered_product_options.on order detail page i am fetching products releted to the particular orders_id and options related to the each product. The problem is i am able to display products in view page in a table using foreach but i want to display the product options variable in the same row as the product. some of the products single option and some have multiple options. Please Help Me to display the product and options in a table.

This is My collections which is i am using in the View

"product" => Collection {#201 ▼
#items: array:1 [▼
  0 => {#223 ▼
    +"_id": 9
    +"created_at": "2020-02-27 17:06:40"
    +"updated_at": "2020-02-27 17:06:40"
    +"products_id": 52
    +"orders__id": 5
    +"name": "Cap"
    +"price": 90.0
    +"status": 1
    +"quantity": 1
    +"custom_product_id": "UN727"
  }
]

}

 "options" => array:1 [▼
0 => Collection {#220 ▼
  #items: array:2 [▼
    0 => {#225 ▼
      +"_id": 2
      +"created_at": "2020-02-27 17:06:40"
      +"updated_at": "2020-02-27 17:06:40"
      +"ordered_products__id": 9
      +"name": "Color"
      +"value_name": "Green"
      +"addon_price": 0.0
    }
    1 => {#226 ▼
      +"_id": 3
      +"created_at": "2020-02-27 17:06:40"
      +"updated_at": "2020-02-27 17:06:40"
      +"ordered_products__id": 9
      +"name": "Size"
      +"value_name": "Large"
      +"addon_price": 0.0
    }
  ]
}

]

 <table class="table">
        <thead>
                      <tr>
            <th>Product Name</th>
                @if(!empty($order['options']))
            <th>View Option Values</th>

            @endif
        </tr>
        </thead>
        <tbody>
             @foreach($order['product'] as $product)

        <tr>

            <td><strong></strong></td>
         <td>
                                <a href="" class="btn btn-sm btn-icon btn-success"><i class="fa fa-eye"></i></a>
                            </td>
          </tr>

      @endforeach

        </tbody>
    </table>

Currently i am using a different page to show the product options is there any way to show the both products and options on the same page.Thanks in advance.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire