/** * Finds the Faq model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Faq the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Faq::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function actionIndex($id, $module = null) { if ($module != 'faq') { $query = Question::find(); } else { $query = \app\modules\faq\models\Faq::find(); } $query->orderBy('_id ASC'); $query->where(['category' => $id]); Yii::$app->view->title = Category::findOne($id)->name; $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 20]]); return $this->render('index', ['model' => $dataProvider]); }