diff --git a/src/Models/Behaviors/HasRelated.php b/src/Models/Behaviors/HasRelated.php index 6580bfa51..139b07af8 100644 --- a/src/Models/Behaviors/HasRelated.php +++ b/src/Models/Behaviors/HasRelated.php @@ -51,6 +51,7 @@ public function loadRelated(string $browserName): Collection /** @var \A17\Twill\Models\Model $model */ if ($model = $item->related) { $model->setRelation('pivot', $item); + $item->unsetRelation('related'); return $model; } @@ -79,7 +80,7 @@ public function saveRelated(array|Collection $items, string $browserName): void } $firstMatchKey = $itemsToProcess - ->where(fn ($item) => $item->related_id === $id && $item->related_type === $type) + ->where(fn (RelatedItem $item) => $item->related_id == $id && $item->related_type === $type) // We should only have one item always as you cannot select the same items twice. ->keys() ->first();