@@ -15,7 +15,7 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | public function boot() |
| 17 | 17 | { |
| 18 | - $this->app[EngineManager::class]->extend('tntsearch', function ($app) { |
|
| 18 | + $this->app[EngineManager::class]->extend('tntsearch', function($app) { |
|
| 19 | 19 | $tnt = new TNTSearch(); |
| 20 | 20 | |
| 21 | 21 | $driver = config('database.default'); |
@@ -43,7 +43,7 @@ |
||
| 43 | 43 | $tnt->loadConfig($config); |
| 44 | 44 | $tnt->setDatabaseHandle($db->getPdo()); |
| 45 | 45 | |
| 46 | - if(!$model->count()) { |
|
| 46 | + if (!$model->count()) { |
|
| 47 | 47 | $this->info('Nothing to import.'); |
| 48 | 48 | exit(0); |
| 49 | 49 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | $indexedColumns = $rowsTotal ? implode(",", array_keys($model->first()->toSearchableArray())) : ''; |
| 70 | 70 | |
| 71 | - if($recordsDifference == 0) { |
|
| 71 | + if ($recordsDifference == 0) { |
|
| 72 | 72 | $recordsDifference = '<fg=green>Synchronized</>'; |
| 73 | 73 | } else { |
| 74 | 74 | $recordsDifference = "<fg=red>$recordsDifference</>"; |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | private function getSearchableModels() |
| 128 | 128 | { |
| 129 | - $searchableModels = (array)$this->argument('model'); |
|
| 129 | + $searchableModels = (array) $this->argument('model'); |
|
| 130 | 130 | if (empty($searchableModels)) { |
| 131 | 131 | $searchableModels = $this->getSearchableModelsFromClasses(); |
| 132 | 132 | } |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | */ |
| 141 | 141 | private function isSearchableModel($trait) |
| 142 | 142 | { |
| 143 | - return function ($className) use ($trait) { |
|
| 143 | + return function($className) use ($trait) { |
|
| 144 | 144 | $traits = class_uses_recursive($className); |
| 145 | 145 | |
| 146 | 146 | return isset($traits[$trait]); |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | $index->setPrimaryKey($models->first()->getKeyName()); |
| 59 | 59 | |
| 60 | 60 | $index->indexBeginTransaction(); |
| 61 | - $models->each(function ($model) use ($index) { |
|
| 61 | + $models->each(function($model) use ($index) { |
|
| 62 | 62 | $array = $model->toSearchableArray(); |
| 63 | 63 | |
| 64 | 64 | if (empty($array)) { |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | public function delete($models) |
| 85 | 85 | { |
| 86 | 86 | $this->initIndex($models->first()); |
| 87 | - $models->each(function ($model) { |
|
| 87 | + $models->each(function($model) { |
|
| 88 | 88 | $this->tnt->selectIndex("{$model->searchableAs()}.index"); |
| 89 | 89 | $index = $this->tnt->getIndex(); |
| 90 | 90 | $index->setPrimaryKey($model->getKeyName()); |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | // sort models by tnt search result set |
| 221 | - return $model->newCollection(collect($results['ids'])->map(function ($hit) use ($models, $results) { |
|
| 221 | + return $model->newCollection(collect($results['ids'])->map(function($hit) use ($models, $results) { |
|
| 222 | 222 | if (isset($models[$hit])) { |
| 223 | 223 | return $models[$hit]->setAttribute('__tntSearchScore__', $results['docScores'][$hit]); |
| 224 | 224 | } |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | // sort models by tnt search result set |
| 260 | - return $model->newCollection($results['ids'])->map(function ($hit) use ($models) { |
|
| 260 | + return $model->newCollection($results['ids'])->map(function($hit) use ($models) { |
|
| 261 | 261 | if (isset($models[$hit])) { |
| 262 | 262 | return $models[$hit]; |
| 263 | 263 | } |
@@ -421,10 +421,10 @@ discard block |
||
| 421 | 421 | private function applyWheres($builder) |
| 422 | 422 | { |
| 423 | 423 | // iterate over given where clauses |
| 424 | - return collect($this->builder->wheres)->map(function ($value, $key) { |
|
| 424 | + return collect($this->builder->wheres)->map(function($value, $key) { |
|
| 425 | 425 | // for reduce function combine key and value into array |
| 426 | 426 | return [$key, $value]; |
| 427 | - })->reduce(function ($builder, $where) { |
|
| 427 | + })->reduce(function($builder, $where) { |
|
| 428 | 428 | // separate key, value again |
| 429 | 429 | list($key, $value) = $where; |
| 430 | 430 | return $builder->where($key, $value); |
@@ -440,10 +440,10 @@ discard block |
||
| 440 | 440 | private function applyOrders($builder) |
| 441 | 441 | { |
| 442 | 442 | //iterate over given orderBy clauses - should be only one |
| 443 | - return collect($this->builder->orders)->map(function ($value, $key) { |
|
| 443 | + return collect($this->builder->orders)->map(function($value, $key) { |
|
| 444 | 444 | // for reduce function combine key and value into array |
| 445 | 445 | return [$value["column"], $value["direction"]]; |
| 446 | - })->reduce(function ($builder, $orderBy) { |
|
| 446 | + })->reduce(function($builder, $orderBy) { |
|
| 447 | 447 | // separate key, value again |
| 448 | 448 | list($column, $direction) = $orderBy; |
| 449 | 449 | return $builder->orderBy($column, $direction); |