我有Laravel与Mongodb和里面的集合文件是这样的;Laravel,Mongo,@foreach逻辑在视图
},
"et_score": null,
"starting_time": "13:00:00",
"competition": {
"active": true,
"id": NumberInt("46"),
"name": "Liga 1"
},
"awayTeam": {
"venue_id": NumberInt("2454"),
"name": "Team away -> Liga1",
"coach_id": NumberInt("140772"),
"twitter": ""
},
"homeTeam": {
"venue_id": NumberInt("0"),
"name": "Team home -> Liga1",
},
"home_score": NumberInt("1"),
"starting_date": "2016-12-24",
"away_score": NumberInt("1")
}
})
.....
而且我.blade有这个;
....
@foreach($data_user as $league)
<table class='table table-striped table-bordered table-condensed'>
<thead><tr><th>{{$league{"competition.name"} }}</th></tr></thead>
@endforeach
<tbody>
<tr>
@foreach($data_user as $match)
<th>{{$match{"starting_date"} }}</th>
<th>{{$match{"starting_time"} }}</th>
<th>{{$match{"status"} }}</th>
<th>{{$match{"homeTeam.name"} }}</th>
<th>{{$match{"home_score"} }} : {{$match{"away_score"} }} </th>
<th>{{$match{"awayTeam.name"} }}</th>
</tr>
@endforeach
</tbody>
</table>
.....
此打印输出表如下所示;
正如你看到我在团队中的一个“luega表”,并会拨出队“团队首页 - > Liga1”去表Liga1也是“团队首页 - >超级联赛”应在超级联赛等
我知道我缺少@foreach一些逻辑,但我没有这样的事情解决了足够的经验,谢谢
嗨曼努埃尔,得到错误你的建议:试图让4号线 – Ronnin
非对象的属性信息是模型,集合,数组的结果?检查,或添加更多的信息来帮助你,但要记住你正在关闭foreach错误,并生成错误的 –
ErrorException在f1da8afe98aba2781763f1e975725bb2aaa771cf.php第5行: 试图获取非对象的属性来获取非对象的属性(查看:/Volumes/WEB/test/CRUD-Laravel-5.3-with-MongoDB/resources/views/myhome.blade.php) – Ronnin