diff --git a/src/Searchable.php b/src/Searchable.php index def9ca0..b76a2b1 100644 --- a/src/Searchable.php +++ b/src/Searchable.php @@ -426,7 +426,12 @@ public function reIndex() public function onAfterDelete() { $this->service->remove($this->owner); - $this->updateDependentClasses(); + if ($this->queued) { + $reindex = new ReindexAfterWriteJob($this->owner); + singleton('QueuedJobService')->queueJob($reindex); + } else { + $this->updateDependentClasses(); + } } /** @@ -434,7 +439,12 @@ public function onAfterDelete() */ public function onAfterManyManyRelationRemove() { - $this->updateDependentClasses(); + if ($this->queued) { + $reindex = new ReindexAfterWriteJob($this->owner); + singleton('QueuedJobService')->queueJob($reindex); + } else { + $this->updateDependentClasses(); + } } /** @@ -442,7 +452,12 @@ public function onAfterManyManyRelationRemove() */ public function onAfterManyManyRelationAdd() { - $this->updateDependentClasses(); + if ($this->queued) { + $reindex = new ReindexAfterWriteJob($this->owner); + singleton('QueuedJobService')->queueJob($reindex); + } else { + $this->updateDependentClasses(); + } } /**