/** * Defines many-to-many relation with player model via table game_has_player * @return list of games's players */ public function getPlayers() { return $this->hasMany(Player::className(), ['id' => 'player_id'])->viaTable('game_has_player', ['game_id' => 'id'])->select('*, (SELECT presence FROM game_has_player WHERE game_id=' . $this->id . ' AND player_id=players.id LIMIT 1) as presence'); }
/** * @return \yii\db\ActiveQuery */ public function getRes8Owner() { return $this->hasOne(Player::className(), ['id' => 'res8OwnerId'])->from(Player::tableName() . ' pro8'); }
/** * Defines many-to-many relation with player model via table team_has_player * @return list of team's players */ public function getPlayers() { return $this->hasMany(Player::className(), ['id' => 'player_id'])->viaTable('team_has_player', ['team_id' => 'id'])->select('*, (SELECT is_capitan FROM team_has_player WHERE team_id=' . $this->id . ' AND player_id=players.id LIMIT 1) as is_capitan'); }