Completed
Pull Request — master (#367)
by
unknown
33s
created
src/Console/ImportCommand.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
src/Console/StatusCommand.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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]);
Please login to merge, or discard this patch.
src/TNTSearchScoutServiceProvider.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
         });
Please login to merge, or discard this patch.
src/Engines/TNTSearchEngine.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
         $index = $this->tnt->getIndex();
58 58
         $index->setPrimaryKey($models->first()->getKeyName());
59 59
 
60
-        $models->each(function ($model) use ($index) {
60
+        $models->each(function($model) use ($index) {
61 61
             $array = $model->toSearchableArray();
62 62
 
63 63
             if (empty($array)) {
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
     public function delete($models)
83 83
     {
84 84
         $this->initIndex($models->first());
85
-        $models->each(function ($model) {
85
+        $models->each(function($model) {
86 86
             $this->tnt->selectIndex("{$model->searchableAs()}.index");
87 87
             $index = $this->tnt->getIndex();
88 88
             $index->setPrimaryKey($model->getKeyName());
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
             $model->getQualifiedKeyName(), $keys
234 234
         )->get()->keyBy($model->getKeyName());
235 235
 
236
-        return $model->newCollection(collect($keys)->map(function ($hit) use ($models, $results) {
236
+        return $model->newCollection(collect($keys)->map(function($hit) use ($models, $results) {
237 237
             if (isset($models[$hit])) {
238 238
                 return $models[$hit]->setAttribute('__tntSearchScore__', $results['docScores'][$hit]);
239 239
             }
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
         }
273 273
 
274 274
         // sort models by tnt search result set
275
-        return $model->newCollection($results['ids'])->map(function ($hit) use ($models) {
275
+        return $model->newCollection($results['ids'])->map(function($hit) use ($models) {
276 276
             if (isset($models[$hit])) {
277 277
                 return $models[$hit];
278 278
             }
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
             return;
337 337
         }
338 338
 
339
-        if (!file_exists($this->tnt->config['storage'] . "/{$indexName}.index")) {
339
+        if (!file_exists($this->tnt->config['storage']."/{$indexName}.index")) {
340 340
             $indexer = $this->tnt->createIndex("$indexName.index");
341 341
             $indexer->setDatabaseHandle($model->getConnection()->getPdo());
342 342
             $indexer->setPrimaryKey($model->getKeyName());
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
     private function discardIdsFromResultSetByConstraints($builder, $searchResults)
362 362
     {
363 363
         $qualifiedKeyName    = $builder->model->getQualifiedKeyName(); // tableName.id
364
-        $subQualifiedKeyName = 'sub.' . $builder->model->getKeyName(); // sub.id
364
+        $subQualifiedKeyName = 'sub.'.$builder->model->getKeyName(); // sub.id
365 365
 
366 366
         $sub = $this->getBuilder($builder->model)->whereIn(
367 367
             $qualifiedKeyName, $searchResults
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 
370 370
         $discardIds = $builder->model->newQuery()
371 371
             ->select($qualifiedKeyName)
372
-            ->leftJoin(DB::raw('(' . $sub->getQuery()->toSql() . ') as ' . $builder->model->getConnection()->getTablePrefix() . 'sub'), $subQualifiedKeyName, '=', $qualifiedKeyName)
372
+            ->leftJoin(DB::raw('('.$sub->getQuery()->toSql().') as '.$builder->model->getConnection()->getTablePrefix().'sub'), $subQualifiedKeyName, '=', $qualifiedKeyName)
373 373
             ->addBinding($sub->getQuery()->getBindings(), 'join')
374 374
             ->whereIn($qualifiedKeyName, $searchResults)
375 375
             ->whereNull($subQualifiedKeyName)
@@ -440,10 +440,10 @@  discard block
 block discarded – undo
440 440
     private function applyWheres($builder)
441 441
     {
442 442
         // iterate over given where clauses
443
-        return collect($this->builder->wheres)->map(function ($value, $key) {
443
+        return collect($this->builder->wheres)->map(function($value, $key) {
444 444
             // for reduce function combine key and value into array
445 445
             return [$key, $value];
446
-        })->reduce(function ($builder, $where) {
446
+        })->reduce(function($builder, $where) {
447 447
             // separate key, value again
448 448
             list($key, $value) = $where;
449 449
             return $builder->where($key, $value);
@@ -459,10 +459,10 @@  discard block
 block discarded – undo
459 459
     private function applyOrders($builder)
460 460
     {
461 461
         //iterate over given orderBy clauses - should be only one
462
-        return collect($this->builder->orders)->map(function ($value, $key) {
462
+        return collect($this->builder->orders)->map(function($value, $key) {
463 463
             // for reduce function combine key and value into array
464 464
             return [$value["column"], $value["direction"]];
465
-        })->reduce(function ($builder, $orderBy) {
465
+        })->reduce(function($builder, $orderBy) {
466 466
             // separate key, value again
467 467
             list($column, $direction) = $orderBy;
468 468
             return $builder->orderBy($column, $direction);
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
     public function flush($model)
479 479
     {
480 480
         $indexName   = $model->searchableAs();
481
-        $pathToIndex = $this->tnt->config['storage'] . "/{$indexName}.index";
481
+        $pathToIndex = $this->tnt->config['storage']."/{$indexName}.index";
482 482
         if (file_exists($pathToIndex)) {
483 483
             unlink($pathToIndex);
484 484
         }
Please login to merge, or discard this patch.