Ejemplo n.º 1
0
 public function afterSave($insert, $changedAttributes)
 {
     parent::afterSave($insert, $changedAttributes);
     $post = $this->topic;
     (new UserMeta())->saveNewMeta('topic', $this->post_id, 'follow');
     (new NotificationService())->newReplyNotify(\Yii::$app->user->identity, $post, $this, $this->atUsers);
     // 更新回复时间
     $post->lastCommentToUpdate(\Yii::$app->user->identity->username);
     if ($insert) {
         // 评论计数器
         Topic::updateAllCounters(['comment_count' => 1], ['id' => $post->id]);
         // 更新个人总统计
         UserInfo::updateAllCounters(['comment_count' => 1], ['user_id' => $this->user_id]);
     }
     \Yii::$app->cache->set('comment' . $this->id, $this, 0);
 }
Ejemplo n.º 2
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return ArrayHelper::merge(parent::behaviors(), ['class' => CacheableActiveRecord::className()]);
 }
Ejemplo n.º 3
0
 public function afterSave($insert, $changedAttributes)
 {
     parent::afterSave($insert, $changedAttributes);
     Yii::$app->cache->set('comment' . $this->id, $this, 0);
 }