Completed
Push — master ( 93bd3f...984ab4 )
by Nenad
15s
created
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());
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
         }
217 217
 
218 218
         // sort models by tnt search result set
219
-        return $model->newCollection(collect($results['ids'])->map(function ($hit) use ($models, $results) {
219
+        return $model->newCollection(collect($results['ids'])->map(function($hit) use ($models, $results) {
220 220
             if (isset($models[$hit])) {
221 221
                 return $models[$hit]->setAttribute('__tntSearchScore__', $results['docScores'][$hit]);
222 222
             }
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
         }
256 256
 
257 257
         // sort models by tnt search result set
258
-        return $model->newCollection($results['ids'])->map(function ($hit) use ($models) {
258
+        return $model->newCollection($results['ids'])->map(function($hit) use ($models) {
259 259
             if (isset($models[$hit])) {
260 260
                 return $models[$hit];
261 261
             }
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
             return;
322 322
         }
323 323
 
324
-        if (!file_exists($this->tnt->config['storage'] . "/{$indexName}.index")) {
324
+        if (!file_exists($this->tnt->config['storage']."/{$indexName}.index")) {
325 325
             $indexer = $this->tnt->createIndex("$indexName.index");
326 326
             $indexer->setDatabaseHandle($model->getConnection()->getPdo());
327 327
             $indexer->setPrimaryKey($model->getKeyName());
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
     private function discardIdsFromResultSetByConstraints($builder, $searchResults)
347 347
     {
348 348
         $qualifiedKeyName    = $builder->model->getQualifiedKeyName(); // tableName.id
349
-        $subQualifiedKeyName = 'sub.' . $builder->model->getKeyName(); // sub.id
349
+        $subQualifiedKeyName = 'sub.'.$builder->model->getKeyName(); // sub.id
350 350
 
351 351
         $sub = $this->getBuilder($builder->model)->whereIn(
352 352
             $qualifiedKeyName, $searchResults
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
 
355 355
         $discardIds = $builder->model->newQuery()
356 356
             ->select($qualifiedKeyName)
357
-            ->leftJoin(DB::raw('(' . $sub->getQuery()->toSql() . ') as ' . $builder->model->getConnection()->getTablePrefix() . 'sub'), $subQualifiedKeyName, '=', $qualifiedKeyName)
357
+            ->leftJoin(DB::raw('('.$sub->getQuery()->toSql().') as '.$builder->model->getConnection()->getTablePrefix().'sub'), $subQualifiedKeyName, '=', $qualifiedKeyName)
358 358
             ->addBinding($sub->getQuery()->getBindings(), 'join')
359 359
             ->whereIn($qualifiedKeyName, $searchResults)
360 360
             ->whereNull($subQualifiedKeyName)
@@ -425,10 +425,10 @@  discard block
 block discarded – undo
425 425
     private function applyWheres($builder)
426 426
     {
427 427
         // iterate over given where clauses
428
-        return collect($this->builder->wheres)->map(function ($value, $key) {
428
+        return collect($this->builder->wheres)->map(function($value, $key) {
429 429
             // for reduce function combine key and value into array
430 430
             return [$key, $value];
431
-        })->reduce(function ($builder, $where) {
431
+        })->reduce(function($builder, $where) {
432 432
             // separate key, value again
433 433
             list($key, $value) = $where;
434 434
             return $builder->where($key, $value);
@@ -444,10 +444,10 @@  discard block
 block discarded – undo
444 444
     private function applyOrders($builder)
445 445
     {
446 446
         //iterate over given orderBy clauses - should be only one
447
-        return collect($this->builder->orders)->map(function ($value, $key) {
447
+        return collect($this->builder->orders)->map(function($value, $key) {
448 448
             // for reduce function combine key and value into array
449 449
             return [$value["column"], $value["direction"]];
450
-        })->reduce(function ($builder, $orderBy) {
450
+        })->reduce(function($builder, $orderBy) {
451 451
             // separate key, value again
452 452
             list($column, $direction) = $orderBy;
453 453
             return $builder->orderBy($column, $direction);
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
     public function flush($model)
464 464
     {
465 465
         $indexName   = $model->searchableAs();
466
-        $pathToIndex = $this->tnt->config['storage'] . "/{$indexName}.index";
466
+        $pathToIndex = $this->tnt->config['storage']."/{$indexName}.index";
467 467
         if (file_exists($pathToIndex)) {
468 468
             unlink($pathToIndex);
469 469
         }
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.