Skip to content

Commit

Permalink
Update HasTags.php (#523)
Browse files Browse the repository at this point in the history
Make changes to avoid multiple pivotAttached event fired, removing loop into synTagIds method
  • Loading branch information
scramatte authored Dec 9, 2024
1 parent 956dc06 commit 65c07d0
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/HasTags.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,8 @@ protected function syncTagIds($ids, string | null $type = null, $detaching = tru
// Attach any new ids
$attach = array_unique(array_diff($ids, $current));
if (count($attach) > 0) {
collect($attach)->each(function ($id) {
$this->tags()->attach($id, []);
});
$this->tags()->attach($attach, []);

$isUpdated = true;
}

Expand Down

0 comments on commit 65c07d0

Please sign in to comment.