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

Commit

Permalink
Merge pull request #35 from MarQ-ZA/patch-1
Browse files Browse the repository at this point in the history
Remove unused tags
  • Loading branch information
tonydspaniard committed Feb 4, 2018
2 parents 139adc7 + 25b5486 commit 9da660b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Taggable.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ class Taggable extends Behavior
* @var string
*/
public $frequency = 'frequency';
/**
* @var bool
*/
public $removeUnusedTags = false;
/**
* @var string
*/
Expand Down Expand Up @@ -201,5 +205,10 @@ public function beforeDelete($event)
->createCommand()
->delete($pivot, [key($relation->via->link) => $this->owner->getPrimaryKey()])
->execute();

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

0 comments on commit 9da660b

Please sign in to comment.