Skip to content

Commit

Permalink
refactor: toSearchableArray now sets search connection
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Taylor-Jackson committed Jan 27, 2019
1 parent 3ebca18 commit 1301e74
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ public function addToIndex()
}

$instance = $this->first();
$instance->setConnection($instance->getElasticsearchConnectionName());
$query = $this->first()->newQueryWithoutScopes();

return $instance->onSearchConnection(function ($instance) {
$docs = $this->map(function ($model) {
return $model->onSearchConnection(function ($model) {
return $model->toSearchableArray();
}, $model);
});
$docs = $this->map(function ($model, $i) {
return $model->toSearchableArray();
});

$query = $instance->newQueryWithoutScopes();
$success = $query->insert($docs->all());

return $query->insert($docs->all());
}, $instance);
unset($docs);

return $success;
}
}

0 comments on commit 1301e74

Please sign in to comment.