mikebronner / laravel-model-caching

Eloquent model-caching made easy.
MIT License
2.22k stars 212 forks source link

Add pivotSynced event listener to flush cache when performing BelongsToMany::sync #433

Closed d8vjork closed 1 year ago

d8vjork commented 1 year ago

As title describes, we've multiple issues on our Laravel 9 based project when users saving stuff on our API.

Apparently this "stuff" has all to do with using sync (in multiple cases required for our business logic to work with the feature design).

So that's how I've found that the pivotSynced event was already available in laravel-pivot-events but not mentioned here.

I'll later today send some commits verifying / testing this scenario I had

Bjornftw commented 1 year ago

@d8vjork Thanks for your PR. Waiting for merge so we can use laravel-model-caching again

mikebronner commented 1 year ago

@d8vjork thanks for your work on this. Please send me an update as soon as your PR is finished. Thanks! :)

d8vjork commented 1 year ago

Ok I've no idea how tests works, even disabling most of these event listeners tests passes 🤔

Will try to replicate the same test as attach/detach in BelongsToMany then

d8vjork commented 1 year ago

@mikebronner Ok test added and passing, ready to merge

Bjornftw commented 1 year ago

@mikebronner any updates?

mikebronner commented 1 year ago

@Bjornftw @d8vjork Thanks for the updates. I will take a look this weekend. :) I appreciate all you contributions! This really helps.