Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.7.10] AsPivot - SoftDelete not working anymore (#26158) #27266

Closed
lk77 opened this issue Jan 22, 2019 · 2 comments
Closed

[5.7.10] AsPivot - SoftDelete not working anymore (#26158) #27266

lk77 opened this issue Jan 22, 2019 · 2 comments
Labels

Comments

@lk77
Copy link

lk77 commented Jan 22, 2019

  • Laravel Version:5.7.10
  • PHP Version:7.2.9
  • Database Driver & Version: mysql 5.7

Description:

Hello,

we have a problem with a change made in that pull request (#26158) that was published under laravel 5.7.10.
The scopes are not taken into account anymore, and it cause unexpected problems,
we are handling the soft delete of pivot elements ourselves (something like ModelClass::deleted(closure)) and we are calling delete() function on the pivot instance,
and it's not working anymore, the entries are really deleted in the table and not soft deleted.
it's because of the replacement of newQuery() by newModelQuery() in AsPivot, which ignore the scopes.

Steps To Reproduce:

1 \ Check that pivot class implement SoftDelete
2 \ Check that pivot relation has a using() call with the correct pivot class
3 \ Get a pivot instance, like $object->relation()->first()->pivot
4 \ Call the delete function $pivot->delete()
5 \ Check the database, rows are gone
6 \ Replace newModelQuery by newQuery in AsPivot
7 \ Repeat step 3 and 4, and check that rows are now correctly soft-deleted

The only fix for us seems to be using deleted_at property directly, without calling ->delete(), but it's more like a hack than a real solution.

Thanks.

@lk77 lk77 changed the title AsPivot - SoftDelete not working anymore (#26158) [5.7.10] AsPivot - SoftDelete not working anymore (#26158) Jan 22, 2019
@driesvints
Copy link
Member

@staudenmeir can you take a look at this perhaps? Thanks!

@lk77
Copy link
Author

lk77 commented Jan 24, 2019

thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants