-
Notifications
You must be signed in to change notification settings - Fork 340
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
[9.x] Fix removing queued models with custom Scout keys #480
Conversation
@stevebauman seems to break the test suite. |
@driesvints Okay we're all set! Fixed the test and style issues 👍 |
Co-authored-by: Dries Vints <dries@vints.io>
So does this replace #479? |
Yup it does! |
I see that the docs already contains the recommendation to change the https://laravel.com/docs/8.x/scout#configuring-the-model-id
So we're good to go on that front as well. |
Purpose
This PR patches the issue described in PR #479.
Description
This PR fixes the issue described above. However, if developers are customizing their Scout key via
getScoutKey()
and are utilizing queuing, they must also modify thegetScoutKeyName()
to return the name of this custom key, so that the models can be hydrated and be properly removed from indexes. I can also submit a PR to the docs repo if this gets merged in so it can instruct developers to perform this step when queuing using custom scout keys.The
RemoveableScoutCollection
class extends the Eloquent collection class, and pulls the queueable ID's from the model'sgetScoutKey()
method. This is the cleanest solution I was able to come up with the least possible intrusion and work on the developers side.In regards to the issue posted in the above PR, they would simply have to add this into their model after this patch:
Let me know if there's any issues/comments/concerns with this approach. Thanks for your time! ❤️