【发布时间】:2021-01-28 13:54:15
【问题描述】:
matches 表与 score 表有关系。
我需要在分数表中获取所有没有记录的匹配项。
尝试过,但没有成功:
$upcomingMatch = Match::join('scores', 'matches.id', '=', 'scores.match_id')
->where('away_team_id', '=', '1')
->orWhere('home_team_id', '=', '1')
->where('scores.match_id', null)
->latest('matches.match_date')
->first();
【问题讨论】:
-
他们之间有建立关系吗?如果是这样,请检查
doesntHave方法 -
我非常同意@lagbox,如果您设置了关系,那么 doesnsHave 是这里标准且简单的解决方案。 laravel.com/docs/8.x/…
标签: php laravel model-view-controller laravel-query-builder