@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | public function boot() |
| 17 | 17 | { |
| 18 | - app(EngineManager::class)->extend('solr', function ($app) { |
|
| 18 | + app(EngineManager::class)->extend('solr', function($app) { |
|
| 19 | 19 | $config = [ |
| 20 | 20 | 'endpoint' => [ |
| 21 | 21 | 'default' => [ |
@@ -29,10 +29,10 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | $adapter = new Curl(); |
| 31 | 31 | $eventDispatcher = new EventDispatcher(); |
| 32 | - $client = new Client($adapter,$eventDispatcher,$config); |
|
| 33 | - if(config('scout.solr.username')){ |
|
| 32 | + $client = new Client($adapter, $eventDispatcher, $config); |
|
| 33 | + if (config('scout.solr.username')) { |
|
| 34 | 34 | $client->getEndpoint() |
| 35 | - ->setAuthentication(config('scout.solr.username'),config('scout.solr.password')); |
|
| 35 | + ->setAuthentication(config('scout.solr.username'), config('scout.solr.password')); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | return new SolrEngine($client); |
@@ -40,19 +40,19 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | $query = $this->client->createUpdate(); |
| 42 | 42 | |
| 43 | - $models->each(function ($model) use (&$query) { |
|
| 44 | - $attrs = array_filter($model->toSearchableArray(), function ($value) { |
|
| 43 | + $models->each(function($model) use (&$query) { |
|
| 44 | + $attrs = array_filter($model->toSearchableArray(), function($value) { |
|
| 45 | 45 | return !\is_null($value); |
| 46 | 46 | }); |
| 47 | 47 | |
| 48 | 48 | // Make sure there is an ID in the array, |
| 49 | 49 | // otherwise we will create duplicates all the time. |
| 50 | 50 | if (!\array_key_exists('id', $attrs)) { |
| 51 | - $attrs['id'] = $model->getScoutKey(); |
|
| 51 | + $attrs[ 'id' ] = $model->getScoutKey(); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | // Add model class to attributes for flushing. |
| 55 | - $attrs['_class'] = \get_class($model); |
|
| 55 | + $attrs[ '_class' ] = \get_class($model); |
|
| 56 | 56 | |
| 57 | 57 | $document = $query->createDocument($attrs); |
| 58 | 58 | $query->addDocument($document); |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | return; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - $ids = $models->map(function ($model) { |
|
| 78 | + $ids = $models->map(function($model) { |
|
| 79 | 79 | return $model->getScoutKey(); |
| 80 | 80 | }); |
| 81 | 81 | |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | public function mapIds($results) |
| 123 | 123 | { |
| 124 | - $ids = array_map(function ($document) { |
|
| 124 | + $ids = array_map(function($document) { |
|
| 125 | 125 | return $document->id; |
| 126 | 126 | }, $results->getDocuments()); |
| 127 | 127 | |
@@ -144,13 +144,13 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | $models = $model->getScoutModelsByIds( |
| 146 | 146 | $builder, collect($results->getDocuments())->pluck('id')->values()->all() |
| 147 | - )->keyBy(function ($model) { |
|
| 147 | + )->keyBy(function($model) { |
|
| 148 | 148 | return $model->getScoutKey(); |
| 149 | 149 | }); |
| 150 | 150 | |
| 151 | - return Collection::make($results->getDocuments())->map(function ($document) use ($models) { |
|
| 152 | - if (isset($models[$document['id']])) { |
|
| 153 | - return $models[$document['id']]; |
|
| 151 | + return Collection::make($results->getDocuments())->map(function($document) use ($models) { |
|
| 152 | + if (isset($models[ $document[ 'id' ] ])) { |
|
| 153 | + return $models[ $document[ 'id' ] ]; |
|
| 154 | 154 | } |
| 155 | 155 | })->filter()->values(); |
| 156 | 156 | } |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | $class = \is_object($model) ? \get_class($model) : false; |
| 178 | 178 | if ($class) { |
| 179 | 179 | // replace \ with \\ |
| 180 | - $class = str_replace("\\","\\\\",$class); |
|
| 180 | + $class = str_replace("\\", "\\\\", $class); |
|
| 181 | 181 | $query = $this->client->createUpdate(); |
| 182 | 182 | $query->addDeleteQuery("_class:{$class}"); |
| 183 | 183 | $query->addCommit(); |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | { |
| 198 | 198 | $selectQuery = $this->client->createSelect(); |
| 199 | 199 | |
| 200 | - $conditions = (empty($builder->query)) ? [] : [$builder->query]; |
|
| 200 | + $conditions = (empty($builder->query)) ? [ ] : [ $builder->query ]; |
|
| 201 | 201 | $conditions = array_merge($conditions, $this->filters($builder)); |
| 202 | 202 | |
| 203 | 203 | $selectQuery->setQuery(implode(' ', $conditions)); |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | */ |
| 220 | 220 | protected function filters(Builder $builder) |
| 221 | 221 | { |
| 222 | - return collect($builder->wheres)->map(function ($value, $key) { |
|
| 222 | + return collect($builder->wheres)->map(function($value, $key) { |
|
| 223 | 223 | return sprintf('%s:"%s"', $key, $value); |
| 224 | 224 | })->values()->all(); |
| 225 | 225 | } |