/** * @return ActiveQuery */ public function getCategory() { return $this->hasOne(CategoryModels::className(), ['id' => 'category_id']); }
/** * This action render the index page. * @return string */ public function actionIndex() { $categories = CategoryModels::find()->with(['forums'])->orderBy('display_position')->all(); return $this->render('index', ['categories' => $categories]); }