Example #1
0
 /**
  * Creates a new commentary model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new commentary();
     $model->load(Yii::$app->request->post());
     $model->postid = $_GET['idpost'];
     if (Yii::$app->user->isGuest) {
         $model->status = " (anonimus)";
     } else {
         $model->user = Yii::$app->user->identity->nickname;
     }
     if ($model->save()) {
         return $this->redirect(['post/view', 'id' => $model->postid]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }