【发布时间】:2019-01-13 12:28:31
【问题描述】:
我的代码是这样写的:
$teams = TeamTeam::query()
->selectRaw('team_teams.title, team_teams.team_structure_id, team_teams.id,
team_teams.description')
->join('team_structures','team_teams.team_structure_id',"=",'team_structures.id')
->where('team_structures.organization_id',session()->get('organization_id'))
->orderBy('team_structures.created_at','desc');
$teams = $teams->get();
我想使用 from with 而不是 join like :
TeamTeam::with('TeamStructure')... 并在 team_structures 表中设置 where 语句。我怎么能用它??!!
谢谢。
【问题讨论】:
-
我认为我们需要更多的信息。也许是您当前的结果和预期的结果。
-
我想像 with('TeamStructure') 一样使用“with”加入并设置 where 语句;我目前的结果是正确的。我想知道如何使用该语句编写代码!