Skip to content
This repository has been archived by the owner on Jul 31, 2018. It is now read-only.

Commit

Permalink
Finish env + slaves. Fixes #35
Browse files Browse the repository at this point in the history
  • Loading branch information
maxiloc committed Oct 27, 2015
1 parent 0c53970 commit 7104405
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/AlgoliaEloquentTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,19 +147,22 @@ public function _setSettings()
$slaves_settings = $modelHelper->getSlavesSettings($this);
$slaves = isset($settings['slaves']) ? $settings['slaves'] : [];

$b = count($slaves) > 0;
$b = true;

/** @var \AlgoliaSearch\Index $index */
foreach ($indices as $index) {
if ($b) {

if ($b && isset($settings['slaves'])) {
$settings['slaves'] = array_map(function ($indexName) use ($modelHelper) {
return $modelHelper->getFinalIndexName($this, $indexName);
}, $settings['slaves']);
}

$index->setSettings($settings);
if (count(array_keys($settings)) > 0) {
$index->setSettings($settings);
}

if ($b) {
if ($b && isset($settings['slaves'])) {
$b = false;
unset($settings['slaves']);
}
Expand All @@ -171,7 +174,8 @@ public function _setSettings()

$s = array_merge($settings, $slaves_settings[$slave]);

$index->setSettings($s);
if (count(array_keys($s)) > 0)
$index->setSettings($s);
}
}
}
Expand Down

0 comments on commit 7104405

Please sign in to comment.