コード例 #1
0
ファイル: User.php プロジェクト: CatherineCD/project
 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')]);
 }