laravel 5.4不存在日期的方法 拉威尔5.4 PHP7.0.0

laravel 5.4不存在日期的方法 拉威尔5.4 PHP7.0.0,php,laravel,Php,Laravel,错误消息: 错误异常 方法,其中日期不存在 大家好,当我使用whereDate时,我的刀片有问题 我的代码: @foreach($game_fields as $game_field) @foreach($game_field->games->whereDate('game_start', \Carbon\Carbon::parse($datum))->groupBy('group_id') as $game) {{ $game[0]->gro

错误消息:

错误异常
方法,其中日期不存在

大家好,当我使用whereDate时,我的刀片有问题

我的代码:


@foreach($game_fields as $game_field)
    @foreach($game_field->games->whereDate('game_start', \Carbon\Carbon::parse($datum))->groupBy('group_id') as $game)
        
            {{ $game[0]->group->name}}
            {{ $game[0]->group->games->count() }}
        
    @endforeach
@endforeach
我正在尝试显示所有游戏字段,并且在每个游戏字段中显示将在特定的$date之前玩的所有游戏,但要按组显示,请按组名称显示,如下所示:

游戏场1 组名|匹配数
-第1组| 5
-第3组| 6
-第6组| 4

第二场 组名|匹配数
-第5组| 4
-第7组| 6
-第11组| 4

我有3个模块:游戏场,小组,游戏

在Games db表中,我有:

$table->increments('id');
$table->integer('team_1_id')->unsigned()->index();
$table->integer('team_2_id')->unsigned()->index();
$table->integer('game_field_id')->unsigned();
$table->datetime('game_start');
游戏场表:

$table->increments('id');
$table->string('name');
$table->increments('id');
$table->string('name');
组字段表:

$table->increments('id');
$table->string('name');
$table->increments('id');
$table->string('name');
游戏模块:

public function game_field(){
    return $this->belongsTo('App\GameField','game_field_id', 'id');
}

public function group(){
    return $this->belongsTo('App\Group','group_id', 'id');
}
游戏场模块:

 public function games(){
    return $this->hasMany('App\Games','game_field_id', 'id');
}

还有别的办法吗?请帮助
$game\u field->games
illumb\Database\elount\Collection
的实例,而不是
illumb\Database\Query\Builder
的实例,您应该使用

@foreach($game_field->games()->whereDate('game_start', \Carbon\Carbon::parse($datum))->groupBy('group_id')->get() as $game)

        {{ $game->group->name}}
        {{ $game->group->games->count() }}

@endforeach