Skip to content

Commit

Permalink
fix bug with update existing pivot and polymorphic many to many
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed May 29, 2020
1 parent 00e9ed7 commit 684208b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Illuminate/Database/Eloquent/Relations/MorphToMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,19 @@ public function getRelationExistenceQuery(Builder $query, Builder $parentQuery,
);
}

/**
* Get the pivot models that are currently attached.
*
* @return \Illuminate\Support\Collection
*/
protected function getCurrentlyAttachedPivots()
{
return parent::getCurrentlyAttachedPivots()->map(function ($record) {
return $record->setMorphType($this->morphType)
->setMorphClass($this->morphClass);
});
}

/**
* Create a new query builder for the pivot table.
*
Expand Down

5 comments on commit 684208b

@devXbian
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
After this release, sync method on existing polymorphic many to many relation started giving error : Call to undefined method Illuminate\Database\Eloquent\Relations\Pivot::setMorphType()", though sync method on creating relation is working fine, only facing issue in polymorphic many to may relation update using sync

However, its working perfectly fine in laravel 6.18.14

Please update if anything needs to be done on my side

Quick response would be appreciable

@GrahamCampbell
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was already fixed in 6.18.18. Please upgrade again.

@devXbian
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, verified, Thanks a lot for quick response.

@LasseRafn
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think 6.18.17 should be deleted, seems wrong to have a broken build live?

@driesvints
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LasseRafn we never delete releases like that. Please upgrade to the latest patch release.

Please sign in to comment.