diff --git a/modules/api/models/Book.php b/modules/api/models/Book.php index 5ab8c7f..025bc25 100644 --- a/modules/api/models/Book.php +++ b/modules/api/models/Book.php @@ -116,10 +116,7 @@ public function attributeLabels(): array { } public function afterSave($insert, $changedAttributes) { - // If this is not a new record, unlink all records related through relationship 'activities' - if (array_key_exists('bookmark', $changedAttributes)) { - parent::afterSave($insert, $changedAttributes); - } else { + if(array_key_exists('tags', $changedAttributes)) { if (!$this->isNewRecord) { $this->unlinkAll('tags', true); } @@ -127,9 +124,10 @@ public function afterSave($insert, $changedAttributes) { $tag = Tag::findOne($tag_id); $this->link('tags', $tag); } - if (array_key_exists('text', $changedAttributes)) { - $this->saveTextToFs(); - } + + } + if (array_key_exists('text', $changedAttributes)) { + $this->saveTextToFs(); } parent::afterSave($insert, $changedAttributes); }