вы не можете использовать этот код. Я надеюсь, что полезно для вас:
getMessagesFor
метод:
public function getMessagesFor(Request $request)
{
$seasons = [ 2005, 2006,2007,
2008,
2009,
2010,
2011,
2012,
2013,
2014,
2015,
2016];
$seasonFinal=[];
foreach($seasons as $session) {
$seasonFinal['win'][$session]=GameData::where('team', $id)->where('win', '1')
->where('stage', 'R16')
->where('round', 'final')
->where('year', $session)
->count();
$seasonFinal['loss'][$session]=GameData::where('team', $id)->
where('loss', '1')
->where('stage', 'R16')
->where('round', 'final')
->where('year', $session)
->count();
}
return view('welcome3',compact('seasonFinal'));
}
welcome3
просмотр:
<table border="1">
@if($seasonFinal)
@foreach($seasonFinal as $key=>$years)
<td>type : {{$key}}</td>
<td>count </td>
@foreach($years as $year=>$count)
<tr>
<td>{{$year}}</td>
<td>{{$count}}</td>
</tr>
@endforeach
@endforeach
@endif
</table>
результат:
<table border="1">
<tbody><tr><td>type : win</td>
<td>count </td>
</tr><tr>
<td>2005</td>
<td>0</td>
</tr>
<tr>
<td>2006</td>
<td>0</td>
</tr>
<tr>
<td>2007</td>
<td>0</td>
</tr>
<tr>
<td>2008</td>
<td>0</td>
</tr>
<tr>
<td>2009</td>
<td>0</td>
</tr>
<tr>
<td>2010</td>
<td>0</td>
</tr>
<tr>
<td>2011</td>
<td>0</td>
</tr>
<tr>
<td>2012</td>
<td>1</td>
</tr>
<tr>
<td>2013</td>
<td>0</td>
</tr>
<tr>
<td>2014</td>
<td>0</td>
</tr>
<tr>
<td>2015</td>
<td>2</td>
</tr>
<tr>
<td>2016</td>
<td>1</td>
</tr>
<tr><td>type : loss</td>
<td>count </td>
</tr><tr>
<td>2005</td>
<td>0</td>
</tr>
<tr>
<td>2006</td>
<td>0</td>
</tr>
<tr>
<td>2007</td>
<td>0</td>
</tr>
<tr>
<td>2008</td>
<td>0</td>
</tr>
<tr>
<td>2009</td>
<td>0</td>
</tr>
<tr>
<td>2010</td>
<td>0</td>
</tr>
<tr>
<td>2011</td>
<td>1</td>
</tr>
<tr>
<td>2012</td>
<td>0</td>
</tr>
<tr>
<td>2013</td>
<td>0</td>
</tr>
<tr>
<td>2014</td>
<td>1</td>
</tr>
<tr>
<td>2015</td>
<td>0</td>
</tr>
<tr>
<td>2016</td>
<td>0</td>
</tr>
</tbody></table>
При необходимости вы можете создавать различные стили и режимы для своего стола.
например, это другая модель:
getMessagesFor
метод:
public function getMessagesFor(Request $request)
{
$seasons = [ 2005, 2006,2007,
2008,
2009,
2010,
2011,
2012,
2013,
2014,
2015,
2016];
$seasonFinal=[];
foreach($seasons as $session) {
$seasonFinal[$session]['win']=GameData::where('team', $id)->where('win', '1')
->where('stage', 'R16')
->where('round', 'final')
->where('year', $session)
->count();
$seasonFinal[$session]['loss']=GameData::where('team', $id)->
where('loss', '1')
->where('stage', 'R16')
->where('round', 'final')
->where('year', $session)
->count();
}
return view('welcome3',compact('seasonFinal'));
}
welcome3
просмотр:
<table border="1">
@if($seasonFinal)
<tr>
<td>year </td>
<td> win count</td>
<td> loss count</td>
</tr>
@foreach($seasonFinal as $year=>$value)
<tr>
<td>{{$year}}</td>
<td> {{$value['win']}}</td>
<td> {{$value['loss']}}</td>
</tr>
@endforeach
@endif
</table>
результат: