我有Laravel和Mongodb以及这样的内部收集文件;
},
"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牌桌”中并将球队分配到“Team Home - &gt; Liga1”进入桌面Liga1并且“Team Home - &gt; Super League”应该在Superliga等
我知道我在@foreach中遗漏了一些逻辑,但我没有足够的经验来解决这个问题,谢谢
答案 0 :(得分:0)
我不明白你想要做什么,但从我看到他们打开或关闭你的foreach错误,除了糟糕的模型使用之外,还会产生糟糕的html。
查看以下内容
@foreach($data_user as $league)
<table class='table table-striped table-bordered table-condensed'>
<thead>
<tr>
<th>{{$league->competition->name }}</th>
</tr>
</thead>
<tbody>
@foreach($data_user as $match)
<tr>
<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>
@endforeach
答案 1 :(得分:0)
如果您看到模型和控制器
,也许更多帮助模型:
<?php
namespace App\Models;
use Moloquent;
class PrimaryModels extends Moloquent
{
protected $collection = 'football.live';
}
控制器:
<?php
namespace App\Http\Controllers;
use App\Models\PrimaryModels as Moloquent;
use Illuminate\Http\Request;
use Input, Redirect;
class PrimaryController2 extends Controller
{
function index(){
return Redirect::to('myhome');
}
function pages($template){
$getAllData = Moloquent::all();
return view($template, ['data_user' => $getAllData]);
}
}
答案 2 :(得分:0)
但是,如果我这样做,那么所有球队都在所有联赛中都有可能。
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occured. Program will exit.