|
10 | 10 | use Illuminate\Support\Facades\DB; |
11 | 11 | use OmniTerm\HasOmniTerm; |
12 | 12 | use PDPhilip\Elasticsearch\Connection; |
13 | | -use PDPhilip\Elasticsearch\Eloquent\HasMappingDefinition; |
14 | 13 | use PDPhilip\Elasticsearch\Eloquent\Model; |
15 | 14 | use PDPhilip\Elasticsearch\Schema\Blueprint; |
16 | 15 | use PDPhilip\Elasticsearch\Schema\Builder as SchemaBuilder; |
@@ -174,21 +173,17 @@ private function resolveModel(): ?Model |
174 | 173 | return null; |
175 | 174 | } |
176 | 175 |
|
177 | | - if (! is_subclass_of($class, HasMappingDefinition::class)) { |
| 176 | + if (! $class::hasMappingDefinition()) { |
178 | 177 | $this->newLine(); |
179 | 178 | $this->omni->statusError('Missing mapping definition', $class, [ |
180 | | - 'Your model must implement HasMappingDefinition:', |
| 179 | + 'Your model must override mappingDefinition():', |
181 | 180 | '', |
182 | | - 'use PDPhilip\Elasticsearch\Eloquent\HasMappingDefinition;', |
183 | 181 | 'use PDPhilip\Elasticsearch\Schema\Blueprint;', |
184 | 182 | '', |
185 | | - 'class YourModel extends Eloquent implements HasMappingDefinition', |
| 183 | + 'public static function mappingDefinition(Blueprint $index): void', |
186 | 184 | '{', |
187 | | - ' public static function mappingDefinition(Blueprint $index): void', |
188 | | - ' {', |
189 | | - ' $index->keyword(\'status\');', |
190 | | - ' $index->geoPoint(\'location\');', |
191 | | - ' }', |
| 185 | + ' $index->keyword(\'status\');', |
| 186 | + ' $index->geoPoint(\'location\');', |
192 | 187 | '}', |
193 | 188 | ]); |
194 | 189 | $this->newLine(); |
@@ -250,7 +245,6 @@ private function setupFromModel(Model $model): void |
250 | 245 | $this->tempIndexName = $this->indexName.'_temp'; |
251 | 246 | $this->connectionName = $model->getConnectionName(); |
252 | 247 |
|
253 | | - /** @var Connection $connection */ |
254 | 248 | $this->connection = DB::connection($this->connectionName); |
255 | 249 | $this->schema = $this->connection->getSchemaBuilder(); |
256 | 250 |
|
@@ -603,14 +597,14 @@ private function summary(): void |
603 | 597 | { |
604 | 598 | $duration = round(microtime(true) - $this->startTime, 2); |
605 | 599 |
|
606 | | - $this->omni->hr(); |
607 | | - $this->omni->titleBar('Re-Index Complete', 'emerald'); |
608 | | - $this->omni->tableHeader('Metric', 'Value'); |
609 | | - $this->omni->tableRow('Index', $this->indexName); |
610 | | - $this->omni->tableRow('Original count', number_format($this->originalCount)); |
611 | | - $this->omni->tableRow('Final count', number_format($this->finalCount)); |
612 | | - $this->omni->tableRow('Duration', $duration.'s'); |
613 | | - $this->omni->hr(); |
| 600 | + $data = [ |
| 601 | + 'Index' => $this->indexName, |
| 602 | + 'Original count' => number_format($this->originalCount), |
| 603 | + 'Final count' => number_format($this->finalCount), |
| 604 | + 'Duration' => $duration.'s', |
| 605 | + |
| 606 | + ]; |
| 607 | + $this->omni->dataList($data, 'Re-Index Complete', 'text-emerald-500'); |
614 | 608 | $this->newLine(); |
615 | 609 | } |
616 | 610 |
|
@@ -671,7 +665,7 @@ private function mappingMismatches(): array |
671 | 665 |
|
672 | 666 | $blueprint = Helpers::getLaravelCompatabilityVersion() >= 12 |
673 | 667 | ? new Blueprint($this->connection, $this->indexName) |
674 | | - : new Blueprint($this->indexName); |
| 668 | + : new Blueprint($this->indexName); // @phpstan-ignore arguments.count |
675 | 669 | ($this->mappingDefinition)($blueprint); |
676 | 670 |
|
677 | 671 | $mismatches = []; |
|
0 commit comments