【发布时间】:2015-05-29 16:43:40
【问题描述】:
我与模型 Competition 和 Season 有一个多对多的关系,其中包含一个名为 Competition_season 的数据透视表。
Season->belongsToMany->Competitions->hasMany->Teams->hasMany->Players
我想查询一个球队在特定赛季的所有球员的数据。
类似
\App\Player::with('team.competition.season')->where('team.competition.season.id', 2);
但是,由于赛季是一个集合(比赛有很多赛季),此时我永远无法这样查询它。
谁能指出我正确选择特定赛季球队中所有球员的正确方向?
【问题讨论】:
-
我相信你应该在最后加上
->get()