[6.x] Fix missing statement preventing deletion#33648
Conversation
The delete method was missing a statement which prevented the deletion of many to many polymorphic pivot models.
GrahamCampbell
left a comment
There was a problem hiding this comment.
Could you add a test covering this?
| public function delete() | ||
| { | ||
| if (isset($this->attributes[$this->getKeyName()])) { | ||
| return (int) parent::delete(); |
There was a problem hiding this comment.
Why is this cast needed?
There was a problem hiding this comment.
Hello, To be honest, I don't know.
I just took the code from the laravel 7.x branch since the use case worked there.
Sorry, I am a beginner and I really don't know how to write tests |
|
@taylorotwell It looks like the original PR was #32421. I'm not sure why 7.x was targetted instead of 6.x. The author didn't explain their choice of branch, and it wasn't discussed. |
|
Yes that's the same problem I had |
|
So, this is just a bug fix backport? |
|
@taylorotwell Yes, I think so |
|
I still don't follow why there is an int cast. |
|
The code comes originally from the AsPivot trait |
Maybe in case to make sure what this function is returning is |
The MorphPivot delete method was missing a statement which prevented the deletion of many to many polymorphic custom pivot models.
This pull request is related to #33647 and should fix the issue.