@@ -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,6 +43,9 @@ discard block |
||
| 43 | 43 | }); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | + /** |
|
| 47 | + * @param TNTSearch $tnt |
|
| 48 | + */ |
|
| 46 | 49 | protected function setFuzziness($tnt) |
| 47 | 50 | { |
| 48 | 51 | $tnt->fuzziness = config('scout.tntsearch.fuzziness', $tnt->fuzziness); |
@@ -51,6 +54,9 @@ discard block |
||
| 51 | 54 | $tnt->fuzzy_max_expansions = config('scout.tntsearch.fuzzy.max_expansions', $tnt->fuzzy_max_expansions); |
| 52 | 55 | } |
| 53 | 56 | |
| 57 | + /** |
|
| 58 | + * @param TNTSearch $tnt |
|
| 59 | + */ |
|
| 54 | 60 | protected function setAsYouType($tnt) |
| 55 | 61 | { |
| 56 | 62 | $tnt->asYouType = config('scout.tntsearch.asYouType', $tnt->asYouType); |
@@ -291,6 +291,7 @@ |
||
| 291 | 291 | * The constraints usually remove only a small amount of results, which is why the non |
| 292 | 292 | * matching results are looked up and removed, instead of returning a collection with |
| 293 | 293 | * all the valid results. |
| 294 | + * @param Builder $builder |
|
| 294 | 295 | */ |
| 295 | 296 | private function discardIdsFromResultSetByConstraints($builder, $searchResults) |
| 296 | 297 | { |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | $index->indexBeginTransaction(); |
| 62 | 62 | $geoindex->indexBeginTransaction(); |
| 63 | - $models->each(function ($model) use ($index, $geoindex) { |
|
| 63 | + $models->each(function($model) use ($index, $geoindex) { |
|
| 64 | 64 | $array = $model->toSearchableArray(); |
| 65 | 65 | |
| 66 | 66 | if (empty($array)) { |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | |
| 70 | 70 | if ($model->getKey()) { |
| 71 | 71 | $index->update($model->getKey(), $array); |
| 72 | - $geoindex->prepareAndExecuteStatement('DELETE FROM locations WHERE doc_id = :documentId;',[ |
|
| 72 | + $geoindex->prepareAndExecuteStatement('DELETE FROM locations WHERE doc_id = :documentId;', [ |
|
| 73 | 73 | ['key' => ':documentId', 'value' => $model->getKey()] |
| 74 | 74 | ]); |
| 75 | 75 | } else { |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | public function delete($models) |
| 100 | 100 | { |
| 101 | 101 | $this->initIndex($models->first()); |
| 102 | - $models->each(function ($model) { |
|
| 102 | + $models->each(function($model) { |
|
| 103 | 103 | $this->tnt->selectIndex("{$model->searchableAs()}.index"); |
| 104 | 104 | $index = $this->tnt->getIndex(); |
| 105 | 105 | $index->setPrimaryKey($model->getKeyName()); |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | $this->geotnt->selectIndex("{$model->searchableAs()}.geoindex"); |
| 109 | 109 | $geoindex = $this->geotnt->getIndex(); |
| 110 | - $geoindex->prepareAndExecuteStatement('DELETE FROM locations WHERE doc_id = :documentId;',[ |
|
| 110 | + $geoindex->prepareAndExecuteStatement('DELETE FROM locations WHERE doc_id = :documentId;', [ |
|
| 111 | 111 | ['key' => ':documentId', 'value' => $model->getKey()] |
| 112 | 112 | ]); |
| 113 | 113 | }); |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | // sort models by tnt search result set |
| 243 | - return collect($results['ids'])->map(function ($hit) use ($models) { |
|
| 243 | + return collect($results['ids'])->map(function($hit) use ($models) { |
|
| 244 | 244 | if (isset($models[$hit])) { |
| 245 | 245 | return $models[$hit]; |
| 246 | 246 | } |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | |
| 338 | 338 | $discardIds = $builder->model->newQuery() |
| 339 | 339 | ->select($qualifiedKeyName) |
| 340 | - ->leftJoin(DB::raw('('.$sub->getQuery()->toSql().') as '. $builder->model->getConnection()->getTablePrefix() .'sub'), $subQualifiedKeyName, '=', $qualifiedKeyName) |
|
| 340 | + ->leftJoin(DB::raw('('.$sub->getQuery()->toSql().') as '.$builder->model->getConnection()->getTablePrefix().'sub'), $subQualifiedKeyName, '=', $qualifiedKeyName) |
|
| 341 | 341 | ->addBinding($sub->getQuery()->getBindings(), 'join') |
| 342 | 342 | ->whereIn($qualifiedKeyName, $searchResults) |
| 343 | 343 | ->whereNull($subQualifiedKeyName) |
@@ -408,10 +408,10 @@ discard block |
||
| 408 | 408 | private function applyWheres($builder) |
| 409 | 409 | { |
| 410 | 410 | // iterate over given where clauses |
| 411 | - return collect($this->builder->wheres)->map(function ($value, $key) { |
|
| 411 | + return collect($this->builder->wheres)->map(function($value, $key) { |
|
| 412 | 412 | // for reduce function combine key and value into array |
| 413 | 413 | return [$key, $value]; |
| 414 | - })->reduce(function ($builder, $where) { |
|
| 414 | + })->reduce(function($builder, $where) { |
|
| 415 | 415 | // separate key, value again |
| 416 | 416 | list($key, $value) = $where; |
| 417 | 417 | return $builder->where($key, $value); |
@@ -427,10 +427,10 @@ discard block |
||
| 427 | 427 | private function applyOrders($builder) |
| 428 | 428 | { |
| 429 | 429 | //iterate over given orderBy clauses - should be only one |
| 430 | - return collect($this->builder->orders)->map(function ($value, $key) { |
|
| 430 | + return collect($this->builder->orders)->map(function($value, $key) { |
|
| 431 | 431 | // for reduce function combine key and value into array |
| 432 | 432 | return [$value["column"], $value["direction"]]; |
| 433 | - })->reduce(function ($builder, $orderBy) { |
|
| 433 | + })->reduce(function($builder, $orderBy) { |
|
| 434 | 434 | // separate key, value again |
| 435 | 435 | list($column, $direction) = $orderBy; |
| 436 | 436 | return $builder->orderBy($column, $direction); |