[英]Eloquent - Many to many where not found in the pivot table
我的數據庫設置如......
帳戶 - <Accounts_Games> - 游戲
Accounts
---------
id INT
Accounts_Games
---------
id INT
account_id INT
game_id INT
Games
---------
id INT
我已經設法通過belongsToMany很容易地通過一個帳戶獲得游戲列表。 現在我需要獲取一個帳戶未加入的游戲列表。
我怎樣才能在Eloquent中實現這一目標?
謝謝
我不知道你們每個表中的表字段。
但你可以這樣做:在GamesEloquent文件中添加這樣的1方法:
public function account_not_join()
{
return $this->belongsToMany('Account', 'accounts_games', 'game_id', 'account_id')->where('is_join', 0);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.