예제 #1
0
 public function getGames()
 {
     return $this->hasMany(Game::className(), ['user_id' => 'id']);
 }
예제 #2
0
파일: Player.php 프로젝트: AndriyK/team
 /**
  * Defines many-to-many relation with game model via table game_has_player
  * @return list of games where user has marked his presence
  */
 public function getGames()
 {
     return $this->hasMany(Game::className(), ['id' => 'game_id'])->viaTable('game_has_player', ['player_id' => 'id'])->select('*, (SELECT presence FROM game_has_player WHERE player_id=' . $this->id . ' AND game_id=games.id LIMIT 1) as presence');
 }
예제 #3
0
파일: Team.php 프로젝트: AndriyK/team
 /**
  * Defines one-to-many relation with games table
  * @return \yii\db\ActiveQuery
  */
 public function getGames()
 {
     return $this->hasMany(Game::className(), ['team_id' => 'id'])->andOnCondition(['>', 'datetime', date('Y-m-d H:m:s')]);
 }