mastermarco
8 months ago

Where on foreign table in belongsToMany relation?

Posted 8 months ago by mastermarco

Every of my users can have more "games", I handle it over belongsToMany relation and the connection is saved in "middle table" 'game_users', model: GameUser.

Now I added field "locked"

User.php

public function games(){
    return $this->belongsToMany(Game::class);
}

how can I add condition with model GameUser in this relation games()? Where GameUser locked = 0?

Please sign in or create an account to participate in this conversation.