@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | $index = $this->tnt->getIndex(); |
58 | 58 | $index->setPrimaryKey($models->first()->getKeyName()); |
59 | 59 | |
60 | - $models->each(function ($model) use ($index) { |
|
61 | - if (method_exists($model, 'shouldBeSearchable') && ! $model->shouldBeSearchable()) { |
|
60 | + $models->each(function($model) use ($index) { |
|
61 | + if (method_exists($model, 'shouldBeSearchable') && !$model->shouldBeSearchable()) { |
|
62 | 62 | return; |
63 | 63 | } |
64 | 64 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | public function delete($models) |
87 | 87 | { |
88 | 88 | $this->initIndex($models->first()); |
89 | - $models->each(function ($model) { |
|
89 | + $models->each(function($model) { |
|
90 | 90 | $this->tnt->selectIndex("{$model->searchableAs()}.index"); |
91 | 91 | $index = $this->tnt->getIndex(); |
92 | 92 | $index->setPrimaryKey($model->getKeyName()); |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | } |
221 | 221 | |
222 | 222 | // sort models by tnt search result set |
223 | - return $model->newCollection(collect($results['ids'])->map(function ($hit) use ($models, $results) { |
|
223 | + return $model->newCollection(collect($results['ids'])->map(function($hit) use ($models, $results) { |
|
224 | 224 | if (isset($models[$hit])) { |
225 | 225 | if (isset($this->tnt->config['searchBoolean']) ? $this->tnt->config['searchBoolean'] : false) { |
226 | 226 | return $models[$hit]; |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | } |
264 | 264 | |
265 | 265 | // sort models by tnt search result set |
266 | - return $model->newCollection($results['ids'])->map(function ($hit) use ($models) { |
|
266 | + return $model->newCollection($results['ids'])->map(function($hit) use ($models) { |
|
267 | 267 | if (isset($models[$hit])) { |
268 | 268 | return $models[$hit]; |
269 | 269 | } |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | return; |
328 | 328 | } |
329 | 329 | |
330 | - if (!file_exists($this->tnt->config['storage'] . "/{$indexName}.index")) { |
|
330 | + if (!file_exists($this->tnt->config['storage']."/{$indexName}.index")) { |
|
331 | 331 | $indexer = $this->tnt->createIndex("$indexName.index"); |
332 | 332 | $indexer->setDatabaseHandle($model->getConnection()->getPdo()); |
333 | 333 | $indexer->setPrimaryKey($model->getKeyName()); |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | private function discardIdsFromResultSetByConstraints($builder, $searchResults) |
353 | 353 | { |
354 | 354 | $qualifiedKeyName = $builder->model->getQualifiedKeyName(); // tableName.id |
355 | - $subQualifiedKeyName = 'sub.' . $builder->model->getKeyName(); // sub.id |
|
355 | + $subQualifiedKeyName = 'sub.'.$builder->model->getKeyName(); // sub.id |
|
356 | 356 | |
357 | 357 | $sub = $this->getBuilder($builder->model)->whereIn( |
358 | 358 | $qualifiedKeyName, $searchResults |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | |
361 | 361 | $discardIds = $builder->model->newQuery() |
362 | 362 | ->select($qualifiedKeyName) |
363 | - ->leftJoin(DB::raw('(' . $sub->getQuery()->toSql() . ') as ' . $builder->model->getConnection()->getTablePrefix() . 'sub'), $subQualifiedKeyName, '=', $qualifiedKeyName) |
|
363 | + ->leftJoin(DB::raw('('.$sub->getQuery()->toSql().') as '.$builder->model->getConnection()->getTablePrefix().'sub'), $subQualifiedKeyName, '=', $qualifiedKeyName) |
|
364 | 364 | ->addBinding($sub->getQuery()->getBindings(), 'join') |
365 | 365 | ->whereIn($qualifiedKeyName, $searchResults) |
366 | 366 | ->whereNull($subQualifiedKeyName) |
@@ -431,10 +431,10 @@ discard block |
||
431 | 431 | private function applyWheres($builder) |
432 | 432 | { |
433 | 433 | // iterate over given where clauses |
434 | - return collect($this->builder->wheres)->map(function ($value, $key) { |
|
434 | + return collect($this->builder->wheres)->map(function($value, $key) { |
|
435 | 435 | // for reduce function combine key and value into array |
436 | 436 | return [$key, $value]; |
437 | - })->reduce(function ($builder, $where) { |
|
437 | + })->reduce(function($builder, $where) { |
|
438 | 438 | // separate key, value again |
439 | 439 | list($key, $value) = $where; |
440 | 440 | return $builder->where($key, $value); |
@@ -450,10 +450,10 @@ discard block |
||
450 | 450 | private function applyOrders($builder) |
451 | 451 | { |
452 | 452 | //iterate over given orderBy clauses - should be only one |
453 | - return collect($this->builder->orders)->map(function ($value, $key) { |
|
453 | + return collect($this->builder->orders)->map(function($value, $key) { |
|
454 | 454 | // for reduce function combine key and value into array |
455 | 455 | return [$value["column"], $value["direction"]]; |
456 | - })->reduce(function ($builder, $orderBy) { |
|
456 | + })->reduce(function($builder, $orderBy) { |
|
457 | 457 | // separate key, value again |
458 | 458 | list($column, $direction) = $orderBy; |
459 | 459 | return $builder->orderBy($column, $direction); |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | public function flush($model) |
470 | 470 | { |
471 | 471 | $indexName = $model->searchableAs(); |
472 | - $pathToIndex = $this->tnt->config['storage'] . "/{$indexName}.index"; |
|
472 | + $pathToIndex = $this->tnt->config['storage']."/{$indexName}.index"; |
|
473 | 473 | if (file_exists($pathToIndex)) { |
474 | 474 | unlink($pathToIndex); |
475 | 475 | } |