Skip to content

Commit

Permalink
Merge pull request #32421 from ThomasTrost/fix-morph-pivot-delete
Browse files Browse the repository at this point in the history
[7.x] Fix MorphPivot::delete for models with primary key
  • Loading branch information
taylorotwell authored Apr 17, 2020
2 parents c9de4a9 + 3a9e020 commit f00c767
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Illuminate/Database/Eloquent/Relations/MorphPivot.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ protected function setKeysForSaveQuery(Builder $query)
*/
public function delete()
{
if (isset($this->attributes[$this->getKeyName()])) {
return (int) parent::delete();
}

if ($this->fireModelEvent('deleting') === false) {
return 0;
}
Expand Down

0 comments on commit f00c767

Please sign in to comment.