Skip to content

Commit

Permalink
handle relationship changes for queuing
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Dubuisson committed Oct 12, 2017
1 parent 70fd92c commit 600dfc2
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/Searchable.php
Original file line number Diff line number Diff line change
Expand Up @@ -426,23 +426,38 @@ 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();
}
}

/**
* Update dependent classes after the extended object has been removed from a ManyManyList
*/
public function onAfterManyManyRelationRemove()
{
$this->updateDependentClasses();
if ($this->queued) {
$reindex = new ReindexAfterWriteJob($this->owner);
singleton('QueuedJobService')->queueJob($reindex);
} else {
$this->updateDependentClasses();
}
}

/**
* Update dependent classes after the extended object has been added to a ManyManyList
*/
public function onAfterManyManyRelationAdd()
{
$this->updateDependentClasses();
if ($this->queued) {
$reindex = new ReindexAfterWriteJob($this->owner);
singleton('QueuedJobService')->queueJob($reindex);
} else {
$this->updateDependentClasses();
}
}

/**
Expand Down

0 comments on commit 600dfc2

Please sign in to comment.