/** * @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()]); }
/** * @return $this */ public function getOwnerUser() { return $this->hasOne(User::className(), ['id' => 'user_id'])->viaTable(FightUser::tableName(), ['fight_id' => 'id']); }