Skip to content

Commit 684208b

Browse files
committed
fix bug with update existing pivot and polymorphic many to many
1 parent 00e9ed7 commit 684208b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

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

+13
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,19 @@ public function getRelationExistenceQuery(Builder $query, Builder $parentQuery,
115115
);
116116
}
117117

118+
/**
119+
* Get the pivot models that are currently attached.
120+
*
121+
* @return \Illuminate\Support\Collection
122+
*/
123+
protected function getCurrentlyAttachedPivots()
124+
{
125+
return parent::getCurrentlyAttachedPivots()->map(function ($record) {
126+
return $record->setMorphType($this->morphType)
127+
->setMorphClass($this->morphClass);
128+
});
129+
}
130+
118131
/**
119132
* Create a new query builder for the pivot table.
120133
*

0 commit comments

Comments
 (0)