I have a table, which lists all the data in the database table order . There is a button for each, which when clicked needs to open a modal panel that shows all the order items that associated with that particular order from the database table orderItem. How can I achieve this??
The following is the code that produces the modal panel, which currently lists all the records from orderItems. I need to show only the ones with associated with a certain order id.
<div id="viewOrderItemModal" class="container modal fade modal-lg" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"
aria-label="close">×</button>
<h3 class="text-center">Order Items</h3>
</div>
<div class="modal-body">
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th >Item</th>
<th >Image</th>
<th >Size</th>
<th >Quantity</th>
<th >Total</th>
<th >Status</th>
<th >
</th>
</tr>
</thead>
<tbody id="tableModel">
@foreach($orderItems as $orderItem)
<tr>
<td>{{$orderItem->item->name}}</td>
<td>
<div class="image">
<a href="{{ asset("/images/items/{$orderItem->item->imagePath}") }}"><img style="width: 50px;height: 50px;"
src="{{ asset("/images/items/{$orderItem->item->imagePath}") }}"></a>
</div>
</td>
<td>{{$orderItem->size}}</td>
<td>{{$orderItem->quantity}}</td>
<td style="width: 120px;">Rs. {{$orderItem->subTotal}}.00</td>
<td>{{$orderItem->orderStatus}}</td>
<td>
<a style="margin-bottom: 5px;" onclick="showChangeOrderStatusModal({{$orderItem->id}})" class=" btn btn-success btn-xs">Change Status </a>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
<div style="padding: 5px;" class="modal-footer">
<button style="width: 100px" type="submit" class="btn btn-success pull-left btn-sm ">
Save Change
</button>
<button class="btn" data-dismiss="modal" aria-hidden="true">OK</button>
</div>
</div>
</div>
</div>