public function getForums() { if (Yii::$app->user->can('admin') || Yii::$app->user->can('moder')) { return $this->hasMany(Forums::className(), ['section_id' => 'id'])->orderBy('sort')->inverseOf('section'); } return $this->hasMany(Forums::className(), ['section_id' => 'id'])->where(['state' => Forums::STATE_ACTIVE])->orderBy('sort')->inverseOf('section'); }
public function getForum() { return $this->hasOne(Forums::className(), ['id' => 'forum_id'])->inverseOf('threads'); }
public function actionForumCreate($id = null, $section_id = null) { if (($model = Forums::findOne($id)) === null) { $model = new Forums(['section_id' => $section_id]); } if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect($model->url); } else { $sections = Sections::find()->select(['name'])->indexBy('id')->column(); return $this->render('forum-create', ['model' => $model, 'lang' => $this->lang, 'sections' => $sections]); } }