/** * @param int $id * * @return Character * @throws NotFoundHttpException */ public function loadCharacter($id) { /** @var Character $character */ $model = Character::find()->joinWith('api')->where(['api_account_characters.characterID' => $id, 'api.userID' => \Yii::$app->user->id])->one(); if (!$model) { throw new NotFoundHttpException('Such character does not exist.'); } return $model; }
/** * @return string */ public function actionList() { $this->getView()->addBread('List'); $characters = Character::find()->joinWith('api')->where(['api.userID' => \Yii::$app->user->id])->all(); return $this->render('list', ['characters' => $characters]); }