Skip to content

Commit

Permalink
Update Book.php
Browse files Browse the repository at this point in the history
  • Loading branch information
ufaboy committed Jul 19, 2023
1 parent 4d024f5 commit 0bfa1e9
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions modules/api/models/Book.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,20 +116,18 @@ 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);
}
foreach ($this->tag_ids as $tag_id) {
$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);
}
Expand Down

0 comments on commit 0bfa1e9

Please sign in to comment.