/** * * @param integer|string $id Article id * @param string $cid comment id among article's whole comments. * @param boolean $throwExceptionIfNull * @return Comment * @throws \yii\web\NotFoundHttpException */ public static function getComment($id, $cid, $throwExceptionIfNull = true) { $article = ArticleController::getArticle($id); $comment = Comment::find()->article($article->guid)->id($cid)->one(); if ($throwExceptionIfNull && !$comment) { throw new \yii\web\NotFoundHttpException(static::t('Comment Not Found.')); } return $comment; }
/** * Get all comments belong to article. * @return \rhopress\models\CommentQuery */ public function getComments() { return $this->hasMany(Comment::className(), ['article_guid' => $this->guidAttribute])->inverseOf('article'); }