Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
taylorotwell committed Jun 2, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent a10552d commit 110b129
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Illuminate/Database/Eloquent/Relations/MorphToMany.php
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphPivot;
use Illuminate\Support\Arr;

class MorphToMany extends BelongsToMany
@@ -123,8 +124,10 @@ public function getRelationExistenceQuery(Builder $query, Builder $parentQuery,
protected function getCurrentlyAttachedPivots()
{
return parent::getCurrentlyAttachedPivots()->map(function ($record) {
return $record->setMorphType($this->morphType)
->setMorphClass($this->morphClass);
return $record instanceof MorphPivot
? $record->setMorphType($this->morphType)
->setMorphClass($this->morphClass)
: $record;
});
}

0 comments on commit 110b129

Please sign in to comment.