@@ -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]); |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | */ |
18 | 18 | public function boot() |
19 | 19 | { |
20 | - $this->app[EngineManager::class]->extend('tntsearch', function ($app) { |
|
20 | + $this->app[EngineManager::class]->extend('tntsearch', function($app) { |
|
21 | 21 | $tnt = new TNTSearch(); |
22 | 22 | |
23 | 23 | $driver = config('database.default'); |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | ]); |
41 | 41 | } |
42 | 42 | |
43 | - Builder::macro('constrain', function ($constraints) { |
|
43 | + Builder::macro('constrain', function($constraints) { |
|
44 | 44 | $this->constraints = $constraints; |
45 | 45 | return $this; |
46 | 46 | }); |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | $index = $this->tnt->getIndex(); |
58 | 58 | $index->setPrimaryKey($models->first()->getKeyName()); |
59 | 59 | |
60 | - $models->each(function ($model) use ($index) { |
|
61 | - if (method_exists($model, 'shouldBeSearchable') && ! $model->shouldBeSearchable()) { |
|
60 | + $models->each(function($model) use ($index) { |
|
61 | + if (method_exists($model, 'shouldBeSearchable') && !$model->shouldBeSearchable()) { |
|
62 | 62 | return; |
63 | 63 | } |
64 | 64 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | public function delete($models) |
87 | 87 | { |
88 | 88 | $this->initIndex($models->first()); |
89 | - $models->each(function ($model) { |
|
89 | + $models->each(function($model) { |
|
90 | 90 | $this->tnt->selectIndex("{$model->searchableAs()}.index"); |
91 | 91 | $index = $this->tnt->getIndex(); |
92 | 92 | $index->setPrimaryKey($model->getKeyName()); |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | } |
221 | 221 | |
222 | 222 | // sort models by tnt search result set |
223 | - return $model->newCollection(collect($results['ids'])->map(function ($hit) use ($models, $results) { |
|
223 | + return $model->newCollection(collect($results['ids'])->map(function($hit) use ($models, $results) { |
|
224 | 224 | if (isset($models[$hit])) { |
225 | 225 | if (isset($this->tnt->config['searchBoolean']) ? $this->tnt->config['searchBoolean'] : false) { |
226 | 226 | return $models[$hit]; |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | } |
264 | 264 | |
265 | 265 | // sort models by tnt search result set |
266 | - return $model->newCollection($results['ids'])->map(function ($hit) use ($models) { |
|
266 | + return $model->newCollection($results['ids'])->map(function($hit) use ($models) { |
|
267 | 267 | if (isset($models[$hit])) { |
268 | 268 | return $models[$hit]; |
269 | 269 | } |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | return; |
328 | 328 | } |
329 | 329 | |
330 | - if (!file_exists($this->tnt->config['storage'] . "/{$indexName}.index")) { |
|
330 | + if (!file_exists($this->tnt->config['storage']."/{$indexName}.index")) { |
|
331 | 331 | $indexer = $this->tnt->createIndex("$indexName.index"); |
332 | 332 | $indexer->setDatabaseHandle($model->getConnection()->getPdo()); |
333 | 333 | $indexer->setPrimaryKey($model->getKeyName()); |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | private function discardIdsFromResultSetByConstraints($builder, $searchResults) |
353 | 353 | { |
354 | 354 | $qualifiedKeyName = $builder->model->getQualifiedKeyName(); // tableName.id |
355 | - $subQualifiedKeyName = 'sub.' . $builder->model->getKeyName(); // sub.id |
|
355 | + $subQualifiedKeyName = 'sub.'.$builder->model->getKeyName(); // sub.id |
|
356 | 356 | |
357 | 357 | $sub = $this->getBuilder($builder->model)->whereIn( |
358 | 358 | $qualifiedKeyName, $searchResults |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | |
361 | 361 | $discardIds = $builder->model->newQuery() |
362 | 362 | ->select($qualifiedKeyName) |
363 | - ->leftJoin(DB::raw('(' . $sub->getQuery()->toSql() . ') as ' . $builder->model->getConnection()->getTablePrefix() . 'sub'), $subQualifiedKeyName, '=', $qualifiedKeyName) |
|
363 | + ->leftJoin(DB::raw('('.$sub->getQuery()->toSql().') as '.$builder->model->getConnection()->getTablePrefix().'sub'), $subQualifiedKeyName, '=', $qualifiedKeyName) |
|
364 | 364 | ->addBinding($sub->getQuery()->getBindings(), 'join') |
365 | 365 | ->whereIn($qualifiedKeyName, $searchResults) |
366 | 366 | ->whereNull($subQualifiedKeyName) |
@@ -431,10 +431,10 @@ discard block |
||
431 | 431 | private function applyWheres($builder) |
432 | 432 | { |
433 | 433 | // iterate over given where clauses |
434 | - return collect($this->builder->wheres)->map(function ($value, $key) { |
|
434 | + return collect($this->builder->wheres)->map(function($value, $key) { |
|
435 | 435 | // for reduce function combine key and value into array |
436 | 436 | return [$key, $value]; |
437 | - })->reduce(function ($builder, $where) { |
|
437 | + })->reduce(function($builder, $where) { |
|
438 | 438 | // separate key, value again |
439 | 439 | list($key, $value) = $where; |
440 | 440 | return $builder->where($key, $value); |
@@ -450,10 +450,10 @@ discard block |
||
450 | 450 | private function applyOrders($builder) |
451 | 451 | { |
452 | 452 | //iterate over given orderBy clauses - should be only one |
453 | - return collect($this->builder->orders)->map(function ($value, $key) { |
|
453 | + return collect($this->builder->orders)->map(function($value, $key) { |
|
454 | 454 | // for reduce function combine key and value into array |
455 | 455 | return [$value["column"], $value["direction"]]; |
456 | - })->reduce(function ($builder, $orderBy) { |
|
456 | + })->reduce(function($builder, $orderBy) { |
|
457 | 457 | // separate key, value again |
458 | 458 | list($column, $direction) = $orderBy; |
459 | 459 | return $builder->orderBy($column, $direction); |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | public function flush($model) |
470 | 470 | { |
471 | 471 | $indexName = $model->searchableAs(); |
472 | - $pathToIndex = $this->tnt->config['storage'] . "/{$indexName}.index"; |
|
472 | + $pathToIndex = $this->tnt->config['storage']."/{$indexName}.index"; |
|
473 | 473 | if (file_exists($pathToIndex)) { |
474 | 474 | unlink($pathToIndex); |
475 | 475 | } |