scout-extended
scout-extended copied to clipboard
Changed AggregatorObserver delete & forceDelete Methods to respect Aggregator syncing status
| Q | A |
|---|---|
| Bug fix? | yes |
| New feature? | no |
| BC breaks? | no, I don't think so |
| Related Issue | Fix #285 |
| Need Doc update | no |
Describe your change
This PR changes the AggregatorObserver delete and forceDelete methods to check syncingDisabledFor using the Aggregator class rather than the Model class. This brings these methods inline with the behaviour of the saved method.
It also updates the delete method to reflect changes made in the parent ModelObserver class.
What problem is this fixing?
If you want to use an aggregator but don't want to index individually the models being aggregated, the algolia/scout-extended docs recommend to simply disable syncing for those models, eg...
Laravel\Scout\ModelObserver::disableSyncingFor(Article::class); Laravel\Scout\ModelObserver::disableSyncingFor(Event::class);
However, the AggregatorObserver delete and forceDelete methods were both checking syncingDisabledFor using the Model class rather than the Aggregator class. This meant that if you deleted a model which had syncing disabled (because you only wanted an Aggregated Index and not individual indexes), it was not deleted from the aggregated index.
Conversely, the saved method does check syncingDisabledFor with the Aggregator class, which I believe should be the correct behaviour.