From 8696328bd49e2259db39bd788a90320b6f81abef Mon Sep 17 00:00:00 2001 From: SajtiDH Date: Thu, 28 Mar 2024 11:24:58 +0100 Subject: [PATCH 1/2] Resolving default connection name before parsing it --- src/Illuminate/Database/DatabaseManager.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Illuminate/Database/DatabaseManager.php b/src/Illuminate/Database/DatabaseManager.php index 9239fca06f90..9b97bda4edc7 100755 --- a/src/Illuminate/Database/DatabaseManager.php +++ b/src/Illuminate/Database/DatabaseManager.php @@ -81,9 +81,9 @@ public function __construct($app, ConnectionFactory $factory) */ public function connection($name = null) { - [$database, $type] = $this->parseConnectionName($name); + $name = $name ?: $this->getDefaultConnection(); - $name = $name ?: $database; + [$database, $type] = $this->parseConnectionName($name); // If we haven't created this connection, we'll create it based on the config // provided in the application. Once we've created the connections we will @@ -134,8 +134,6 @@ public function connectUsing(string $name, array $config, bool $force = false) */ protected function parseConnectionName($name) { - $name = $name ?: $this->getDefaultConnection(); - return Str::endsWith($name, ['::read', '::write']) ? explode('::', $name, 2) : [$name, null]; } From 8de13f3a9fac122606bccd61fc789b7c3d3aa7c8 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 28 Mar 2024 09:09:04 -0500 Subject: [PATCH 2/2] formatting --- src/Illuminate/Database/DatabaseManager.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Illuminate/Database/DatabaseManager.php b/src/Illuminate/Database/DatabaseManager.php index 9b97bda4edc7..cf408bc68785 100755 --- a/src/Illuminate/Database/DatabaseManager.php +++ b/src/Illuminate/Database/DatabaseManager.php @@ -134,6 +134,8 @@ public function connectUsing(string $name, array $config, bool $force = false) */ protected function parseConnectionName($name) { + $name = $name ?: $this->getDefaultConnection(); + return Str::endsWith($name, ['::read', '::write']) ? explode('::', $name, 2) : [$name, null]; }