/** * Finds the ArticleInstance model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $article_id * @param string $language * @return ArticleInstance the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($article_id, $language) { if (($model = ArticleInstance::findOne(['article_id' => $article_id, 'language' => $language])) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return string */ public function run() { $dataProvider = new ActiveDataProvider(['query' => ArticleInstance::find()->where(['language' => Yii::$app->language, 'published' => ArticleInstance::PUBLISHED_YES])->with('article')->orderBy('article_id DESC')]); return $this->render('articles_list', ['dataProvider' => $dataProvider]); }
/** * @return \yii\db\ActiveQuery */ public function getArticleInstances() { return $this->hasMany(ArticleInstance::className(), ['article_id' => 'article_id']); }