@@ -6,9 +6,7 @@ |
||
| 6 | 6 | use Nqxcode\LuceneSearch\Search; |
| 7 | 7 | use Symfony\Component\Console\Helper\ProgressBar; |
| 8 | 8 | use Symfony\Component\Console\Output\NullOutput; |
| 9 | - |
|
| 10 | 9 | use App; |
| 11 | -use Config; |
|
| 12 | 10 | |
| 13 | 11 | class RebuildCommand extends Command |
| 14 | 12 | { |
@@ -54,7 +54,7 @@ |
||
| 54 | 54 | $progress = new ProgressBar($this->getOutput(), $count); |
| 55 | 55 | $progress->start(); |
| 56 | 56 | |
| 57 | - $modelRepository->chunk(1000, function ($chunk) use ($progress, $search) { |
|
| 57 | + $modelRepository->chunk(1000, function($chunk) use ($progress, $search) { |
|
| 58 | 58 | foreach ($chunk as $model) { |
| 59 | 59 | $search->update($model); |
| 60 | 60 | $progress->advance(); |
@@ -4,7 +4,6 @@ |
||
| 4 | 4 | |
| 5 | 5 | use BestServedCold\LaravelZendSearch\Search\Wildcard; |
| 6 | 6 | use ZendSearch\Lucene\Index\Term; |
| 7 | -use ZendSearch\Lucene\Search\Query\AbstractQuery; |
|
| 8 | 7 | use ZendSearch\Lucene\Search\Query\Fuzzy; |
| 9 | 8 | use ZendSearch\Lucene\Search\Query\MultiTerm; |
| 10 | 9 | use ZendSearch\Lucene\Search\Query\Phrase; |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | * @param bool $field |
| 115 | 115 | * @param array $options |
| 116 | 116 | */ |
| 117 | - public function wildcard($string, $field = false, $options = []) |
|
| 117 | + public function wildcard($string, $field = false, $options = [ ]) |
|
| 118 | 118 | { |
| 119 | 119 | $this->query->add((new Wildcard($field, $string, $options))->get()); |
| 120 | 120 | } |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | private function mapWhereArray($string, array $array) |
| 161 | 161 | { |
| 162 | - return array_map(function () use ($string) { |
|
| 162 | + return array_map(function() use ($string) { |
|
| 163 | 163 | return $string; |
| 164 | 164 | }, array_flip($array)); |
| 165 | 165 | } |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | */ |
| 190 | 190 | private function mapIds(array $array) |
| 191 | 191 | { |
| 192 | - return array_map(function ($v) { |
|
| 192 | + return array_map(function($v) { |
|
| 193 | 193 | return $v->id; |
| 194 | 194 | }, $array); |
| 195 | 195 | } |
@@ -7,12 +7,12 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | trait SearchTrait |
| 9 | 9 | { |
| 10 | - private static $searchFields = []; |
|
| 11 | - private static $searchParameters = []; |
|
| 10 | + private static $searchFields = [ ]; |
|
| 11 | + private static $searchParameters = [ ]; |
|
| 12 | 12 | |
| 13 | 13 | private static function setup() |
| 14 | 14 | { |
| 15 | - if (! is_subclass_of(static::class, Model::class)) { |
|
| 15 | + if (!is_subclass_of(static::class, Model::class)) { |
|
| 16 | 16 | throw new \Exception( |
| 17 | 17 | 'SearchTrait must only be used with Eloquent models, [' . get_called_class() . '] used' |
| 18 | 18 | ); |
@@ -63,13 +63,13 @@ discard block |
||
| 63 | 63 | $store = App::make(Store::class); |
| 64 | 64 | |
| 65 | 65 | self::saved( |
| 66 | - function (Model $model) use ($store) { |
|
| 66 | + function(Model $model) use ($store) { |
|
| 67 | 67 | self::insertCallback($model, $store); |
| 68 | 68 | } |
| 69 | 69 | ); |
| 70 | 70 | |
| 71 | 71 | self::deleting( |
| 72 | - function (Model $model) use ($store) { |
|
| 72 | + function(Model $model) use ($store) { |
|
| 73 | 73 | self::deleteCallback($model, $store); |
| 74 | 74 | } |
| 75 | 75 | ); |
@@ -26,11 +26,11 @@ |
||
| 26 | 26 | |
| 27 | 27 | private function filterParameters($model) |
| 28 | 28 | { |
| 29 | - if (! empty($model::getSearchParameters())) { |
|
| 29 | + if (!empty($model::getSearchParameters())) { |
|
| 30 | 30 | return $this->filterKeysFromArray($model->attributesToArray(), $model::getSearchParameters()); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - return []; |
|
| 33 | + return [ ]; |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -32,24 +32,24 @@ |
||
| 32 | 32 | __DIR__ . '/../../../config/search.php' => config_path('search.php'), |
| 33 | 33 | ]); |
| 34 | 34 | |
| 35 | - $this->app->singleton('command.search.rebuild', function () { |
|
| 35 | + $this->app->singleton('command.search.rebuild', function() { |
|
| 36 | 36 | return new RebuildCommand; |
| 37 | 37 | }); |
| 38 | 38 | |
| 39 | - $this->app->singleton('command.search.clear', function () { |
|
| 39 | + $this->app->singleton('command.search.clear', function() { |
|
| 40 | 40 | return new ClearCommand; |
| 41 | 41 | }); |
| 42 | 42 | |
| 43 | - $this->app->singleton('command.search.optimise', function () { |
|
| 43 | + $this->app->singleton('command.search.optimise', function() { |
|
| 44 | 44 | return new OptimiseCommand; |
| 45 | 45 | }); |
| 46 | 46 | |
| 47 | - $this->commands(['command.search.rebuild', 'command.search.optimise', 'command.search.clear']); |
|
| 47 | + $this->commands([ 'command.search.rebuild', 'command.search.optimise', 'command.search.clear' ]); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | |
| 51 | 51 | public function provides() |
| 52 | 52 | { |
| 53 | - return ['search', 'command.search.rebuild', 'command.search.optimise', 'command.search.clear']; |
|
| 53 | + return [ 'search', 'command.search.rebuild', 'command.search.optimise', 'command.search.clear' ]; |
|
| 54 | 54 | } |
| 55 | 55 | } |
@@ -6,9 +6,9 @@ |
||
| 6 | 6 | { |
| 7 | 7 | protected $string; |
| 8 | 8 | protected $field = false; |
| 9 | - protected $Options = []; |
|
| 9 | + protected $Options = [ ]; |
|
| 10 | 10 | |
| 11 | - public function __construct($string, $field = false, $options = []) |
|
| 11 | + public function __construct($string, $field = false, $options = [ ]) |
|
| 12 | 12 | { |
| 13 | 13 | $this->string = $string; |
| 14 | 14 | $this->field = $field; |
@@ -85,7 +85,7 @@ |
||
| 85 | 85 | */ |
| 86 | 86 | protected function path() |
| 87 | 87 | { |
| 88 | - if (! $this->path ) { |
|
| 88 | + if (!$this->path) { |
|
| 89 | 89 | throw new \Exception('No path specified nor config variable set.'); |
| 90 | 90 | } |
| 91 | 91 | |
@@ -52,7 +52,7 @@ |
||
| 52 | 52 | * @param boolean|int $uid unique identifier, if required |
| 53 | 53 | * @return mixed |
| 54 | 54 | */ |
| 55 | - public function insert($id, array $fields, array $parameters = [], $uid = false) |
|
| 55 | + public function insert($id, array $fields, array $parameters = [ ], $uid = false) |
|
| 56 | 56 | { |
| 57 | 57 | $this->document->addField($this->field('xref_id', $id)); |
| 58 | 58 | $this->document->addField($this->field('_parameters', $this->flattenParameters($parameters), 'unIndexed')); |
@@ -52,7 +52,7 @@ |
||
| 52 | 52 | * @param boolean|int $uid unique identifier, if required |
| 53 | 53 | * @return mixed |
| 54 | 54 | */ |
| 55 | - public function insert($id, array $fields, array $parameters = [], $uid = false) |
|
| 55 | + public function insert($id, array $fields, array $parameters = [ ], $uid = false) |
|
| 56 | 56 | { |
| 57 | 57 | $this->document->addField($this->field('xref_id', $id)); |
| 58 | 58 | $this->document->addField($this->field('_parameters', $this->flattenParameters($parameters), 'unIndexed')); |