无法从另一个我不知道为什么的表中获取数据
@if(count($shift))
@foreach($shift as $data)
<tr>
<td>{{$data->serial}}</td>
<td>{{$data->date}}</td>
<td>{{$data->startshift}}</td>
<td>{{$data->endshift}}</td>
@foreach($tracking as $track)
<!--here is the problem-->
@endforeach
@endforeach
</tr>
$shift = DB::table('employee_schedule')
->select('id','user_id as user_id','serial as serial','date as date','startshift as startshift','endshift as endshift')
->orderBy('id','ASC')
->paginate(5);
$tracking = DB::table('empsheduling')
->select('serial as serial','date as date','startshift as startshift','endshift as endshift','Hourswork as Hourswork')
->first();
return view('shifTracker.viewshifTracker',compact('shift','tracking'));
答案 0 :(得分:0)
您已经选择了可实现表的第一条记录,请查看查询的结尾:first()
。
将first()
替换为get()
,或者在您的视图中删除循环并使用$tracking->data
获取数据。
答案 1 :(得分:0)
我已经通过将first()更改为get()找到了解决方案。谢谢