public function actionIndex($category_id = null) { if (is_null($category_id)) { $category = new Home(); } else { $category = Category::findOne($category_id); } if ($category->category_id != 0 && is_null($category)) { throw new \yii\web\HttpException(404, Yii::t('burivuh', 'The category does not exist')); } $categories = Category::find()->where(['parent_id' => $category->category_id])->orderBy('title')->all(); $documents = Document::find()->where(['category_id' => $category->category_id])->orderBy('title')->all(); $readme = Document::find()->where(['title' => $category->title, 'category_id' => $category->category_id])->one(); return $this->render('index', ['category' => $category, 'categories' => $categories, 'documents' => $documents, 'readme' => $readme]); }