I want on click of an event ( on click of order) to open the modal with specific order items. In my case, it opens only the last order. So in every event that I click, it shows me the last order and the last items.
<script>
jQuery(document).ready(function($) {
$('#calendar').fullCalendar({
height: 'auto',
header: {
left: 'Calendar',
center: '',
right: 'today prev,next'
},
events : [
@foreach($orders as $order)
{
id: '{{ $order->id }}',
title : 'Order#{{ $order->id}}',
description:'{{ $order->id}}' ,
start : '{{ date('Y-m-d') }}',
color:'#008070',
},
@endforeach
],
eventClick: function(event) {
$("#successModal{{$order->id}}").modal("show");
$('#order_id').val(calEvent._id);
$("#successModal .modal-body p").text(event.title);
}
});
});
</script>
<div class="modal fade" id="successModal{{$order->id}}" tabindex="-1" role="dialog" aria-labelledby="successModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<table class="table table-condensed table-hover">
<tbody>
@php
$items=App\Order_Items::where('id_order',$order->id)->get();
@endphp
@foreach($items as $item)
<tr>
<td align="center">
</td>
<td align="center">
@php
$total = $item->price / $item->quantity;
@endphp
{{ $total }}
</td >
<td align="center">{{$item->quantity}} </td>
<td class="text-center sbold" align="center">{{number_format($item->price)}} </td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
What should I do in this case ? I am trying to figure out the problem but still don't understand why this happens.