請不要告訴我把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 –