@@ -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,13 +60,13 @@ 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 | if (empty($array)) return; |
| 66 | 66 | |
| 67 | 67 | if ($model->getKey()) { |
| 68 | 68 | $index->update($model->getKey(), $array); |
| 69 | - $geoindex->prepareAndExecuteStatement('DELETE FROM locations WHERE doc_id = :documentId;',[ |
|
| 69 | + $geoindex->prepareAndExecuteStatement('DELETE FROM locations WHERE doc_id = :documentId;', [ |
|
| 70 | 70 | ['key' => ':documentId', 'value' => $model->getKey()] |
| 71 | 71 | ]); |
| 72 | 72 | } else { |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | public function delete($models) |
| 97 | 97 | { |
| 98 | 98 | $this->initIndex($models->first()); |
| 99 | - $models->each(function ($model) { |
|
| 99 | + $models->each(function($model) { |
|
| 100 | 100 | $this->tnt->selectIndex("{$model->searchableAs()}.index"); |
| 101 | 101 | $index = $this->tnt->getIndex(); |
| 102 | 102 | $index->setPrimaryKey($model->getKeyName()); |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | |
| 105 | 105 | $this->geotnt->selectIndex("{$model->searchableAs()}.geoindex"); |
| 106 | 106 | $geoindex = $this->geotnt->getIndex(); |
| 107 | - $geoindex->prepareAndExecuteStatement('DELETE FROM locations WHERE doc_id = :documentId;',[ |
|
| 107 | + $geoindex->prepareAndExecuteStatement('DELETE FROM locations WHERE doc_id = :documentId;', [ |
|
| 108 | 108 | ['key' => ':documentId', 'value' => $model->getKey()] |
| 109 | 109 | ]); |
| 110 | 110 | }); |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | // sort models by tnt search result set |
| 240 | - return collect($results['ids'])->map(function ($hit) use ($models) { |
|
| 240 | + return collect($results['ids'])->map(function($hit) use ($models) { |
|
| 241 | 241 | if (isset($models[$hit])) { |
| 242 | 242 | return $models[$hit]; |
| 243 | 243 | } |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | |
| 335 | 335 | $discardIds = $builder->model->newQuery() |
| 336 | 336 | ->select($qualifiedKeyName) |
| 337 | - ->leftJoin(DB::raw('('.$sub->getQuery()->toSql().') as '. $builder->model->getConnection()->getTablePrefix() .'sub'), $subQualifiedKeyName, '=', $qualifiedKeyName) |
|
| 337 | + ->leftJoin(DB::raw('('.$sub->getQuery()->toSql().') as '.$builder->model->getConnection()->getTablePrefix().'sub'), $subQualifiedKeyName, '=', $qualifiedKeyName) |
|
| 338 | 338 | ->addBinding($sub->getQuery()->getBindings(), 'join') |
| 339 | 339 | ->whereIn($qualifiedKeyName, $searchResults) |
| 340 | 340 | ->whereNull($subQualifiedKeyName) |
@@ -405,10 +405,10 @@ discard block |
||
| 405 | 405 | private function applyWheres($builder) |
| 406 | 406 | { |
| 407 | 407 | // iterate over given where clauses |
| 408 | - return collect($this->builder->wheres)->map(function ($value, $key) { |
|
| 408 | + return collect($this->builder->wheres)->map(function($value, $key) { |
|
| 409 | 409 | // for reduce function combine key and value into array |
| 410 | 410 | return [$key, $value]; |
| 411 | - })->reduce(function ($builder, $where) { |
|
| 411 | + })->reduce(function($builder, $where) { |
|
| 412 | 412 | // separate key, value again |
| 413 | 413 | list($key, $value) = $where; |
| 414 | 414 | return $builder->where($key, $value); |
@@ -424,10 +424,10 @@ discard block |
||
| 424 | 424 | private function applyOrders($builder) |
| 425 | 425 | { |
| 426 | 426 | //iterate over given orderBy clauses - should be only one |
| 427 | - return collect($this->builder->orders)->map(function ($value, $key) { |
|
| 427 | + return collect($this->builder->orders)->map(function($value, $key) { |
|
| 428 | 428 | // for reduce function combine key and value into array |
| 429 | 429 | return [$value["column"], $value["direction"]]; |
| 430 | - })->reduce(function ($builder, $orderBy) { |
|
| 430 | + })->reduce(function($builder, $orderBy) { |
|
| 431 | 431 | // separate key, value again |
| 432 | 432 | list($column, $direction) = $orderBy; |
| 433 | 433 | return $builder->orderBy($column, $direction); |
@@ -62,7 +62,9 @@ discard block |
||
| 62 | 62 | $geoindex->indexBeginTransaction(); |
| 63 | 63 | $models->each(function ($model) use ($index, $geoindex) { |
| 64 | 64 | $array = $model->toSearchableArray(); |
| 65 | - if (empty($array)) return; |
|
| 65 | + if (empty($array)) { |
|
| 66 | + return; |
|
| 67 | + } |
|
| 66 | 68 | |
| 67 | 69 | if ($model->getKey()) { |
| 68 | 70 | $index->update($model->getKey(), $array); |
@@ -73,7 +75,9 @@ discard block |
||
| 73 | 75 | $index->insert($array); |
| 74 | 76 | } |
| 75 | 77 | |
| 76 | - if (empty($array['longitude']) || empty($array['latitude'])) return; |
|
| 78 | + if (empty($array['longitude']) || empty($array['latitude'])) { |
|
| 79 | + return; |
|
| 80 | + } |
|
| 77 | 81 | $array['longitude'] = (float) $array['longitude']; |
| 78 | 82 | $array['latitude'] = (float) $array['latitude']; |
| 79 | 83 | |