diff --git a/models/Article.php b/models/Article.php index a691832..4e5e906 100755 --- a/models/Article.php +++ b/models/Article.php @@ -4,12 +4,14 @@ use artbox\core\behaviors\ManyToManyBehavior; use artbox\core\models\Image; + use artbox\webcomment\models\CommentModel; use yii\behaviors\TimestampBehavior; use yii\db\ActiveRecord; use artbox\core\behaviors\LanguageBehavior; use artbox\core\models\Language; use yii\db\ActiveQuery; use yii\db\Query; + use yii\helpers\Url; use yii\web\Request; /** @@ -150,12 +152,24 @@ return ( new Query() )->where('1 = 0'); } } + + public function getCommentsCount() + { + + if (class_exists('\artbox\webcomment\models\CommentModel')) { + $comments = CommentModel::find()->where("status = 1 and entity = 'artbox\weblog\models\Article' and entity_id = ".$this->id)->count(); + return $comments; + } else { + return null; + } + } /** * @return Query */ public function getArticleToProduct() { + if (class_exists('\artbox\catalog\models\Product')) { return $this->hasMany(ArticleToProduct::className(), [ 'article_id' => 'id' ]); } else { -- libgit2 0.21.4