public function actionView()
 {
     if (Yii::$app->request->get('id') && Yii::$app->request->get('id') > 0) {
         $post = BlogPost::findOne(Yii::$app->request->get('id'));
         $post->updateCounters(['click' => 1]);
         $comments = BlogComment::find()->where(['post_id' => $post->id, 'status' => Status::STATUS_ACTIVE])->orderBy(['created_at' => SORT_ASC])->all();
         $comment = $this->newComment($post);
     } else {
         $this->redirect(['blog']);
     }
     //var_dump($post->comments);
     return $this->render('view', ['post' => $post, 'comments' => $comments, 'comment' => $comment]);
 }
 /**
  * Finds the BlogPost model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return BlogPost the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = BlogPost::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }