Skip to content

Commit

Permalink
Allow connecting to read or write connections with the db command (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
themsaid committed Jun 1, 2021
1 parent 7ad6ba2 commit db89ad5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Illuminate/Database/Console/DbCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ class DbCommand extends Command
*
* @var string
*/
protected $signature = 'db {connection? : The database connection that should be used}';
protected $signature = 'db {connection? : The database connection that should be used}
{--read : Connect to the read connection}
{--write : Connect to the write connection}';

/**
* The console command description.
Expand Down Expand Up @@ -64,6 +66,12 @@ public function getConnection()
$connection = (new ConfigurationUrlParser)->parseConfiguration($connection);
}

if ($this->option('read')) {
$connection = array_merge($connection, $connection['read']);
} elseif ($this->option('write')) {
$connection = array_merge($connection, $connection['write']);
}

return $connection;
}

Expand Down

0 comments on commit db89ad5

Please sign in to comment.