我只是想显示表格中的数据,您可以在下面的图片中看到:
project_id
指项目表中的项目名称
activity_id
是指活动表中的活动名称
这是我的代码
<table id="list-Dopeople-report" class="table table-bordered responsive">
<tr>
<th>project</th>
@foreach($examples as $key=>$value)
<th>{{activityIdToActivityNameConvert($value->activity->id)}}</th>
@endforeach
</tr>
@foreach($pros as $key=>$value)
<tr>
<th>{{projectIdToProjectNameConvert($value->project->id)}}</th>
</tr>
@endforeach
</table>
任何帮助都是适当的
答案 0 :(得分:0)
这里有几点需要考虑:
主要问题是你只是迭代了&#39; -e元素,这将继续添加行。你不会迭代'td&#39;元素,将填充列
<table id="list-Dopeople-report" class="table table-bordered responsive">
<thead>
<tr>
<th>project</th>
@foreach($examples as $key=>$value)
<th>{{activityIdToActivityNameConvert($value->activity->id)}}</th>
@endforeach
</tr>
</thead>
<tbody>
<!-- here you iterate over the rows, which is ok -->
@foreach($pros as $key=>$value)
<tr>
<td>{{projectIdToProjectNameConvert($value->project->id)}}</td>
<!-- you should also iterate over the columns -->
@foreach($project->activities as $activity)
<td>{{$activity->time}}</td>
@endforeach
</tr>
@endforeach
</tbody>
</table>