示例#1
0
 /**
  * Creates a new Topic model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     if (Yii::$app->user->can('admin')) {
         $model = new Topic();
         if ($model->load(Yii::$app->request->post()) && $model->save()) {
             return $this->redirect(['view', 'id' => $model->topic_id]);
         } else {
             $authors = User::find()->all();
             $category = Category::find()->all();
             return $this->render('create', ['model' => $model, 'authors' => $authors, 'category' => $category]);
         }
     } else {
         $this->goHome();
     }
 }