public function updateCommentTotal() { $model = CommentInfo::find()->where(["entity" => $this->entity, "entity_id" => $this->entity_id])->one(); $total = Comment::activeCount($this->entity, $this->entity_id); if ($model == null && $total != 0) { $model = new CommentInfo(); $model->entity = $this->entity; $model->entity_id = $this->entity_id; $model->total = $total; $model->save(); } else { $model->total = $total; $model->save(); } }
public function afterDelete() { $entity = $this->getEntityClass(); $entity_id = $this->getEntityId(); CommentInfo::deleteAll(['entity' => $entity, 'entity_id' => $entity_id]); Comment::deleteAll(['entity' => $entity, 'entity_id' => $entity_id]); }
* @package hass\package_name * @author zhepama <*****@*****.**> * @since 0.1.0 * */ ?> <?php echo ViewHelper::area(3, ["blockClass" => "sidebar-box-body", "headerClass" => "sidebar-box white animate-onscroll", "bodyClass" => "sidebar-box-header"]); ?> <!-- 评论最多 --> <div class="sidebar-box white animate-onscroll"> <h3>评论最多</h3> <?php $items = \hass\comment\models\CommentInfo::getEntityOrderByTotal(); ?> <div class="week-hot" style="display: block;"> <?php $i = 1; ?> <?php foreach ($items as $item) { ?> <a href="<?php echo \yii\helpers\Url::to(\hass\base\helpers\Util::getEntityUrl($item)); ?> " target="_blank" title=""> <span><?php echo $i;