Fix: propagate connection override to Builder from BaseModel (#58)

This commit is contained in:
Denis Glushkov
2026-04-19 17:27:37 +05:00
parent ec76c2d640
commit 184d0cb9c4
2 changed files with 5 additions and 2 deletions
+1 -1
View File
@@ -319,7 +319,7 @@ class BaseModel
protected function newQuery(): Builder
{
return new Builder($this->getThisClient());
return new Builder($this->getThisClient(), $this->connection);
}
/**
+4 -1
View File
@@ -31,10 +31,13 @@ class Builder extends BaseBuilder
*/
protected $connection = Connection::DEFAULT_NAME;
public function __construct(?Client $client = null)
public function __construct(?Client $client = null, ?string $connection = null)
{
$this->grammar = new Grammar();
$this->client = $client ?? $this->getThisClient();
if ($connection !== null) {
$this->connection = $connection;
}
}
/**