Skip to content

Commit e1ca158

Browse files
authored
Merge pull request #294 from thewebartisan7/patch-1
Fixed commands scout:status and scout:import
2 parents 959f724 + 8cc1951 commit e1ca158

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/Console/ImportCommand.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,16 @@ 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());
50-
$desiredColumns = array_keys($model->toSearchableArray());
55+
$desiredColumns = array_keys($model->first()->toSearchableArray());
5156

5257
$fields = array_intersect($desiredColumns, $availableColumns);
5358

src/Console/StatusCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ public function handle(Dispatcher $events)
6363
$rowsIndexed = 0;
6464
}
6565

66-
$indexedColumns = implode(",", array_keys($model->toSearchableArray()));
67-
6866
$rowsTotal = $model->count();
6967
$recordsDifference = $rowsTotal - $rowsIndexed;
7068

69+
$indexedColumns = $rowsTotal ? implode(",", array_keys($model->first()->toSearchableArray())) : '';
70+
7171
if($recordsDifference == 0) {
7272
$recordsDifference = '<fg=green>Synchronized</>';
7373
} else {
@@ -79,7 +79,7 @@ public function handle(Dispatcher $events)
7979
}
8080

8181
$this->output->progressFinish();
82-
$this->output->table($headers, $rows, $tableStyle = 'default', $columnStyles = []);
82+
$this->output->table($headers, $rows);
8383
}
8484

8585
/**

0 commit comments

Comments
 (0)