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 3fd8d9d commit 96b6ae3
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 @@ -444,23 +444,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 96b6ae3

Please sign in to comment.