Skip to content

Commit ef7c420

Browse files
Merge branch '7.x'
2 parents 3076a81 + a201572 commit ef7c420

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Illuminate/Database/Eloquent/Relations/MorphToMany.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,10 @@ public function getRelationExistenceQuery(Builder $query, Builder $parentQuery,
123123
protected function getCurrentlyAttachedPivots()
124124
{
125125
return parent::getCurrentlyAttachedPivots()->map(function ($record) {
126-
return $record->setMorphType($this->morphType)
127-
->setMorphClass($this->morphClass);
126+
return $record instanceof MorphPivot
127+
? $record->setMorphType($this->morphType)
128+
->setMorphClass($this->morphClass)
129+
: $record;
128130
});
129131
}
130132

0 commit comments

Comments
 (0)