Commit 377f23039ecb4e86b0ff088abde039f29a434032
1 parent
a77af268
-jh
Showing
1 changed file
with
14 additions
and
0 deletions
Show diff stats
models/Article.php
| @@ -4,12 +4,14 @@ | @@ -4,12 +4,14 @@ | ||
| 4 | 4 | ||
| 5 | use artbox\core\behaviors\ManyToManyBehavior; | 5 | use artbox\core\behaviors\ManyToManyBehavior; |
| 6 | use artbox\core\models\Image; | 6 | use artbox\core\models\Image; |
| 7 | + use artbox\webcomment\models\CommentModel; | ||
| 7 | use yii\behaviors\TimestampBehavior; | 8 | use yii\behaviors\TimestampBehavior; |
| 8 | use yii\db\ActiveRecord; | 9 | use yii\db\ActiveRecord; |
| 9 | use artbox\core\behaviors\LanguageBehavior; | 10 | use artbox\core\behaviors\LanguageBehavior; |
| 10 | use artbox\core\models\Language; | 11 | use artbox\core\models\Language; |
| 11 | use yii\db\ActiveQuery; | 12 | use yii\db\ActiveQuery; |
| 12 | use yii\db\Query; | 13 | use yii\db\Query; |
| 14 | + use yii\helpers\Url; | ||
| 13 | use yii\web\Request; | 15 | use yii\web\Request; |
| 14 | 16 | ||
| 15 | /** | 17 | /** |
| @@ -150,12 +152,24 @@ | @@ -150,12 +152,24 @@ | ||
| 150 | return ( new Query() )->where('1 = 0'); | 152 | return ( new Query() )->where('1 = 0'); |
| 151 | } | 153 | } |
| 152 | } | 154 | } |
| 155 | + | ||
| 156 | + public function getCommentsCount() | ||
| 157 | + { | ||
| 158 | + | ||
| 159 | + if (class_exists('\artbox\webcomment\models\CommentModel')) { | ||
| 160 | + $comments = CommentModel::find()->where("status = 1 and entity = 'artbox\weblog\models\Article' and entity_id = ".$this->id)->count(); | ||
| 161 | + return $comments; | ||
| 162 | + } else { | ||
| 163 | + return null; | ||
| 164 | + } | ||
| 165 | + } | ||
| 153 | 166 | ||
| 154 | /** | 167 | /** |
| 155 | * @return Query | 168 | * @return Query |
| 156 | */ | 169 | */ |
| 157 | public function getArticleToProduct() | 170 | public function getArticleToProduct() |
| 158 | { | 171 | { |
| 172 | + | ||
| 159 | if (class_exists('\artbox\catalog\models\Product')) { | 173 | if (class_exists('\artbox\catalog\models\Product')) { |
| 160 | return $this->hasMany(ArticleToProduct::className(), [ 'article_id' => 'id' ]); | 174 | return $this->hasMany(ArticleToProduct::className(), [ 'article_id' => 'id' ]); |
| 161 | } else { | 175 | } else { |