Skip to content

Commit 7de3cd9

Browse files
authored
Merge pull request #227 from SebSzcze/master
Add table prefix to select query
2 parents df9053b + 2e76fea commit 7de3cd9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Console/ImportCommand.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ public function handle(Dispatcher $events)
3434
$class = $this->argument('model');
3535

3636
$model = new $class();
37-
$tnt = new TNTSearch();
37+
$tnt = new TNTSearch();
3838
$driver = $model->getConnectionName() ?: config('database.default');
3939
$config = config('scout.tntsearch') + config("database.connections.$driver");
40+
$tablePrefix = $config['prefix'] ?? '';
41+
$tableName = $tablePrefix.$model->getTable();
4042

4143
$tnt->loadConfig($config);
4244
$tnt->setDatabaseHandle(app('db')->connection($driver)->getPdo());
@@ -55,7 +57,7 @@ public function handle(Dispatcher $events)
5557
$query = '*';
5658
}
5759

58-
$indexer->query("SELECT $query FROM {$model->getTable()};");
60+
$indexer->query("SELECT $query FROM {$tableName};");
5961

6062
$indexer->run();
6163
$this->info('All ['.$class.'] records have been imported.');

0 commit comments

Comments
 (0)