Closed Uteev closed 8 months ago
Hi @Uteev!
The lazy()
method fetches the database entries using PHP generators, it should work as well.
I also tested this with our demo, both locally and in online: https://demo.backpackforlaravel.com/admin/monster/140/edit#relationship.
While adding new and removing old ones, it works.
I'm clueless, @pxpm, do you know any situation where ->lazy()->each
could not work?
Me too it seems to work on my side. @Uteev can you replicate this in our demo project: https://github.com/Laravel-Backpack/demo or in a clean install ? I want to exclude the possibility of being some project specific issue.
Cheers
Hey @Uteev we really want to get to the bottom of this. Can you please try to reproduce in our demo, so we know what to test?
Closing due to inactivity. If the bug persist, please re-open.
Cheers
I have relationship field. It uses HasMany relation. When I remove related item and click "Save & Back" button it does not delete from database the removed related item.
I tried to debug the problem and I find out that the problem occurs in Backpack\CRUD\app\Library\CrudPanel\Traits\Create on the line 324
$entry->{$relationMethod}()->whereNotIn($relatedModelLocalKey, $relatedItemsSent)->lazy()->each->delete();
If I remove from this code lazy()->each so it become
$entry->{$relationMethod}()->whereNotIn($relatedModelLocalKey, $relatedItemsSent)->delete();
then it works perfectly.
I could not understand why lazy()->each not working.