public function afterInsert()
 {
     $postData = \Yii::$app->request->post($this->owner->formName());
     $status = $postData['commentEnabled'];
     if ($status == $this->defaultStatus) {
         return;
     }
     $model = new CommentInfo();
     $model->entity = $this->getEntityClass();
     $model->entity_id = $this->getEntityId();
     $model->status = $status;
     $model->save();
 }
Beispiel #2
0
 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();
     }
 }