Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

Commit

Permalink
dont increase the frequancy field if its null
Browse files Browse the repository at this point in the history
  • Loading branch information
kurpievski committed Apr 9, 2019
1 parent 9da660b commit 1f33603
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Taggable.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ public function afterSave($event)
$tag->{$this->name} = $name;
}

$tag->{$this->frequency}++;
if (!is_null($tag->{$this->frequency})) {
$tag->{$this->frequency}++;
}

if ($tag->save()) {
$updatedTags[] = $tag;
Expand Down Expand Up @@ -205,7 +207,7 @@ public function beforeDelete($event)
->createCommand()
->delete($pivot, [key($relation->via->link) => $this->owner->getPrimaryKey()])
->execute();

if ($this->removeUnusedTags)
{
$class::deleteAll([$this->frequency => 0]);
Expand Down

0 comments on commit 1f33603

Please sign in to comment.