/**
  * Creates a new Comment model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Comment();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('createComment', ['model' => $model]);
     }
 }
 /**
  * Displays a single Blog model.
  * @param integer $id
  * @return mixed
  */
 public function actionView($id)
 {
     $comment = new Comment();
     if ($comment->load(\Yii::$app->request->post())) {
         $comment->blog_id = $id;
         $comment->status = Comment::STATUS_PENDING;
         if ($comment->save()) {
             Yii::$app->session->setFlash('commentAdded');
             return $this->redirect('');
         } else {
             throw new \yii\base\UserException('Не удалось добавить комментарий, сообщите об этом администратору сайта.');
         }
     }
     return $this->render('viewBlog', ['model' => $this->findModel($id), 'comment' => $comment]);
 }