/** * @return string */ public function actionIndex() { $query = Fight::find(); $fu = FightUser::tableName(); $query->join('LEFT JOIN', $fu, $fu . '.fight_id = ' . Fight::tableName() . '.id AND ' . $fu . '.user_id = ' . \Yii::$app->user->getIdentity()->cid); $query->where($fu . '.id IS NULL'); $query->orderBy('created_at DESC'); $items = new ActiveDataProvider(['query' => $query, 'sort' => false]); return $this->render('index', ['items' => $items, 'model' => new FightForm()]); }
/** * Get game instance * @param $id * @return Game */ public function getFight($id) { if (!isset($this->fights[$id])) { $game = new Game(); $game->setFight(Fight::find()->where('id = :id', [':id' => $id])->one()); $game->setManager($this); $this->fights[$id] = $game; unset($game); } return $this->fights[$id]; }