请不要告诉我把orderBy放在函数内部,因为这是行不通的。 kill_count和death_count是roleplay
关系Laravel命令通过使用2个表?
列这里是我的全码:
$topCredits = Player::whereHas("roleplay", function($q) {
$q->where('government_id', '<', '1');
})->orderBy('credits', 'DESC')->limit(10)->get();
$topKills = Player::whereHas("roleplay", function($q) {
$q->where('government_id', '<', '1')->orderBy('kill_count', 'DESC');
})->limit(10)->get();
$topDeaths = Player::whereHas("roleplay", function($q) {
$q->where('government_id', '<', '1')->orderBy('death_count', 'DESC');
})->limit(10)->get();
现在,第一$topCredits
作品完美,但底部2没有。他们工作得很好,除了它并没有通过death_count和kill_count命令,任何人都可以帮忙吗? roleplay
是hasOne在两边的关系。
什么是球员和角色扮演之间的关系? –
HasOne和HasOne –