Closed lukacavic closed 5 years ago
@lukacavic Thanks for reporting this. I'll have a look in the next few days.
Hi, thanks for reply. Maybe suggestion. Please check this image. I think this is bug. https://imgur.com/bNyE4qw.
instead $instance should be $relationshipInstance. When I changed this, it is ok, no bug.
@lukacavic Nice catch!
Tnx, dont know to use GitHub to make a pull request. Please can you write a comment when you fix this? Thanks
Sure thing, probably later today or tomorrow. :)
Looking forward for this. I recently updated to laravel 5.8 and my composer.json entirely and my test are only failing on this.
Working on tis now, hope to have a fix out in the next few hours. Writing a test for this scenario, is a bit tricky.
@lukacavic Can you provide a your complete eloquent model of your User and Books and Link Announcements? I'm having a difficult time recreating the problem.
Also please provide the full code you use to delete and detach.
The call to the code you posted the image of only happens if both models are cached. However, you are right in that the code needs to be fixed. I'm just trying to recreate the original issue so I can develop a test for this.
Hi, @mikebronner, I will post it tomorow..
Short description:
I have User model, does not use Cachable trait. I also have Announcement model, it uses Cachable trait. I also have a Person model, it does not use Cachable trait. I have link table link_announcement_receivers, that has morphs column "receiver", receiver can be person or user. Becouse announcement can be posted for user or for person.
Now, in AnnouncementController, when I delete announcement, I also want to detach linked users and linked persons from link table. I use: $announcement->users() - >detach() ; and $announcement->persons() - >detach() ; users() and persons() use morphs relationship.
When I execute that code to remove persons and users I get error.
Ok, I will post my code in day or two.
Thanks
It would be great to have the patch. I'm stopping the 5.8 update release until the flushCache issue is patched.
The @lukacavic patch worked for me. Actually is just a typo so I don't know if you need a test for that. Maybe you can merge it?
EDITED: It's already merged! Sorry for bothering you. Thank you and keep to good work!
Hi, I have this error when performing some operations. For example: I have a user model, I did not add Cachable trait to it. Also I have Announcement model, that model has Cachable trait. I have link table link_announcement_users, and when I delete announcement, I also call: $announcement->users()->detach(); to remove entries from link table. And get this error