@@ -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); |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | $index->setPrimaryKey($models->first()->getKeyName()); |
| 47 | 47 | |
| 48 | 48 | $index->indexBeginTransaction(); |
| 49 | - $models->each(function ($model) use ($index) { |
|
| 49 | + $models->each(function($model) use ($index) { |
|
| 50 | 50 | $array = $model->toSearchableArray(); |
| 51 | 51 | |
| 52 | 52 | if (empty($array)) { |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | public function delete($models) |
| 73 | 73 | { |
| 74 | 74 | $this->initIndex($models->first()); |
| 75 | - $models->each(function ($model) { |
|
| 75 | + $models->each(function($model) { |
|
| 76 | 76 | $this->tnt->selectIndex("{$model->searchableAs()}.index"); |
| 77 | 77 | $index = $this->tnt->getIndex(); |
| 78 | 78 | $index->setPrimaryKey($model->getKeyName()); |
@@ -115,8 +115,8 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | $searchResults = $results['ids']; |
| 117 | 117 | |
| 118 | - $qualifiedKeyName = $builder->model->getQualifiedKeyName(); // tableName.id |
|
| 119 | - $subQualifiedKeyName = 'sub.' . $builder->model->getKeyName(); // sub.id |
|
| 118 | + $qualifiedKeyName = $builder->model->getQualifiedKeyName(); // tableName.id |
|
| 119 | + $subQualifiedKeyName = 'sub.'.$builder->model->getKeyName(); // sub.id |
|
| 120 | 120 | |
| 121 | 121 | $sub = $this->getBuilder($builder->model)->whereIn( |
| 122 | 122 | $qualifiedKeyName, $searchResults |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | */ |
| 140 | 140 | $discardIds = $builder->model->newQuery() |
| 141 | 141 | ->select($qualifiedKeyName) |
| 142 | - ->leftJoin(DB::raw('(' . $sub->getQuery()->toSql() .') as sub'), $subQualifiedKeyName, '=', $qualifiedKeyName) |
|
| 142 | + ->leftJoin(DB::raw('('.$sub->getQuery()->toSql().') as sub'), $subQualifiedKeyName, '=', $qualifiedKeyName) |
|
| 143 | 143 | ->addBinding($sub->getQuery()->getBindings(), 'join') |
| 144 | 144 | ->whereIn($qualifiedKeyName, $searchResults) |
| 145 | 145 | ->whereNull($subQualifiedKeyName) |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | */ |
| 209 | 209 | protected function filters(Builder $builder) |
| 210 | 210 | { |
| 211 | - return collect($builder->wheres)->map(function ($value, $key) { |
|
| 211 | + return collect($builder->wheres)->map(function($value, $key) { |
|
| 212 | 212 | return $key.'='.$value; |
| 213 | 213 | })->values()->all(); |
| 214 | 214 | } |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | |
| 232 | 232 | $builder = $this->getBuilder($model); |
| 233 | 233 | |
| 234 | - if($this->builder->queryCallback){ |
|
| 234 | + if ($this->builder->queryCallback) { |
|
| 235 | 235 | call_user_func($this->builder->queryCallback, $builder); |
| 236 | 236 | } |
| 237 | 237 | |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | // sort models by tnt search result set |
| 248 | - return collect($results['ids'])->map(function ($hit) use ($models) { |
|
| 248 | + return collect($results['ids'])->map(function($hit) use ($models) { |
|
| 249 | 249 | if (isset($models[$hit])) { |
| 250 | 250 | return $models[$hit]; |
| 251 | 251 | } |
@@ -266,20 +266,20 @@ discard block |
||
| 266 | 266 | $builder = isset($this->builder->constraints) ? $this->builder->constraints : $model->newQuery(); |
| 267 | 267 | |
| 268 | 268 | // iterate over given where clauses |
| 269 | - $builder = collect($this->builder->wheres)->map(function ($value, $key) { |
|
| 269 | + $builder = collect($this->builder->wheres)->map(function($value, $key) { |
|
| 270 | 270 | // for reduce function combine key and value into array |
| 271 | 271 | return [$key, $value]; |
| 272 | - })->reduce(function ($builder, $where) { |
|
| 272 | + })->reduce(function($builder, $where) { |
|
| 273 | 273 | // separate key, value again |
| 274 | 274 | list($key, $value) = $where; |
| 275 | 275 | return $builder->where($key, $value); |
| 276 | 276 | }, $builder); |
| 277 | 277 | |
| 278 | 278 | //iterate over given orderBy clauses - should be only one |
| 279 | - return collect($this->builder->orders)->map(function ($value, $key) { |
|
| 279 | + return collect($this->builder->orders)->map(function($value, $key) { |
|
| 280 | 280 | // for reduce function combine key and value into array |
| 281 | 281 | return [$value["column"], $value["direction"]]; |
| 282 | - })->reduce(function ($builder, $orderBy) { |
|
| 282 | + })->reduce(function($builder, $orderBy) { |
|
| 283 | 283 | // separate key, value again |
| 284 | 284 | list($column, $direction) = $orderBy; |
| 285 | 285 | return $builder->orderBy($column, $direction); |