Skip to content

Commit a8b5138

Browse files
authored
Merge pull request #26 from racibaz/FixIssue25
The unused $targetConnection is made dynamic.
2 parents 905fc60 + 7e0edb1 commit a8b5138

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/Console/DbSyncCommand.php

+8-5
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,15 @@ public function handle(): bool
3838
$mysqldumpSkipTzUtc = config('dbsync.mysqldumpSkipTzUtc') ? '--skip-tz-utc' : '';
3939

4040
$targetConnection = config('dbsync.targetConnection');
41+
$defaultConnection = config('database.default');
4142

42-
$localUsername = config('database.connections.mysql.username');
43-
$localPassword = config('database.connections.mysql.password');
44-
$localHostname = config('database.connections.mysql.host');
45-
$localPort = config('database.connections.mysql.port');
46-
$localDatabase = config('database.connections.mysql.database');
43+
$defaultConnection = empty($targetConnection) ? $defaultConnection: $targetConnection;
44+
45+
$localUsername = config("database.connections.{$defaultConnection}.username");
46+
$localPassword = config("database.connections.{$defaultConnection}.password");
47+
$localHostname = config("database.connections.{$defaultConnection}.host");
48+
$localPort = config("database.connections.{$defaultConnection}.port");
49+
$localDatabase = config("database.connections.{$defaultConnection}.database");
4750
$localMysqlPath = config('dbsync.localMysqlPath');
4851

4952
if (empty($host) || empty($username) || empty($database)) {

0 commit comments

Comments
 (0)