3
我的這個代碼在我的trips.blade.php中。問題是當我的$ t->員工不在模態中時,我檢索了所有員工,但是當我將我的$ t->員工放入模態中時,我只能檢索1個數據。在這種情況下,我找不出任何錯誤。模態內部的不同輸出(Laravel 5.4)
@foreach($trips as $t)
<tr>
<td>{{$t->id}}</td>
<td>{{$t->dateMilled_trip}}</td>
<td>{{$t->ticket->ticketNumber_ticket}}</td> \t
<td>{{$t->truckNumber_trip}}</td>
<td>{{$t->finalWeight_trip}}</td>
<td>
{{$t->employees}} -> Here it shows all the employees inside trip
<a class="btn btn-info btn-xs" data-toggle="modal" data-target="#viewEmployeesAttendanceTicket">View Employees Attendance</a>
<!-- Modal -->
<div class="modal fade" id="viewEmployeesAttendanceTicket" tabindex="-1" role="dialog" aria-labelledby="James Order List">
<div class="modal-dialog" role="document">
<div class="modal-content">
{{$t->employees}} ->Here it show only 1 employee data
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">{{$t->ticket->ticketNumber_ticket}} Attendances</h4>
</div>
<div class="modal-body">
<table class="table table-striped">
<thead>
<tr>
<th>#</th>
<th>Employee Name</th>
</tr>
</thead>
<tbody>
@foreach($t->employees as $emp) ->same here [1 Data only]
<tr>
<td>{{$emp->id}}</td>
<td>{{$emp->name_employee}}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</td>
<td>
<div class="btn-group" role="group" aria-label="...">
<a class="btn btn-danger btn-xs">DELETE</a>
</div>
</td>
</tr>
@endforeach
哇,謝謝。這解決了我的問題。 :) – james
你非常歡迎。如果您認爲這是一個解決方案,請將其標記爲解決方案。謝謝 –