Skip to content

Commit a282c31

Browse files
Same issue like in scout:status
The `$model->toSearchableArray()` return empty array so all columns become indexed.
1 parent dd3b5db commit a282c31

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Console/ImportCommand.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,18 @@ public function handle(Dispatcher $events)
4343
$tnt->loadConfig($config);
4444
$tnt->setDatabaseHandle($db->getPdo());
4545

46+
if(!$model->count()) {
47+
$this->info('Nothing to import.');
48+
exit(0);
49+
}
50+
4651
$indexer = $tnt->createIndex($model->searchableAs().'.index');
4752
$indexer->setPrimaryKey($model->getKeyName());
4853

4954
$availableColumns = Schema::connection($driver)->getColumnListing($model->getTable());
5055
$desiredColumns = array_keys($model->toSearchableArray());
5156

52-
$fields = array_intersect($desiredColumns, $availableColumns);
57+
$desiredColumns = array_keys($model->first()->toSearchableArray());
5358

5459
$query = $db->table($model->getTable());
5560

0 commit comments

Comments
 (0)