common\models\PostComment::afterSave PHP Method

afterSave() public method

public afterSave ( $insert, $changedAttributes )
    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);
    }