From d809bc79775342423964baf948c0559b44c43e0e Mon Sep 17 00:00:00 2001 From: scramatte Date: Mon, 9 Dec 2024 13:29:18 +0100 Subject: [PATCH] Update HasTags.php Make changes to avoid multiple pivotAttached event fired, removing loop into synTagIds method --- src/HasTags.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/HasTags.php b/src/HasTags.php index 801cb24..78beab7 100644 --- a/src/HasTags.php +++ b/src/HasTags.php @@ -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; }