public function actionIndex() { $categoryRepo = new CategoryRepository(); $categories = $categoryRepo->getAll('id_category IS NOT NULL'); $themes = $categoryRepo->getThemes(); return $this->render('index', ['categories' => $categories, 'themes' => $themes]); }
/** * Creates a new ForumCategory model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new ForumCategory(); $model->createdAt = date("Y-m-d H:i:s", time()); $model->updatedAt = date("Y-m-d H:i:s", time()); $model->id_user = Yii::$app->user->id; $categoryRepo = new CategoryRepository(); $themes = $categoryRepo->getThemes(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['/forum/default/index']); } else { return $this->render('create', ['model' => $model, 'themes' => $themes]); } }