/**
  * Finds the PostComment model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return PostComment the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = PostComment::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 public static function getCommentsByPostId($post_id)
 {
     $result = PostComment::where('post_id', $post_id)->get();
     return $result;
 }
 /**
  * Displays a single Post model.
  * @param integer $id
  * @return mixed
  */
 public function actionView($id)
 {
     $comment = new PostComment();
     $comment->post_id = $id;
     return $this->render('view', ['model' => $this->findModel($id), 'comment' => $comment, 'commentsDataProvider' => new ActiveDataProvider(['query' => PostComment::find()->where(['post_id' => $id])])]);
 }