Skip to content

Commit 189b216

Browse files
committed
fix connection issue
1 parent 05ffef6 commit 189b216

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/DynamicModelFactory.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,15 @@ private function getDynamicTableValues(): array
5252

5353
$currentDBConnection = Schema::getConnection()->getName();
5454

55+
$connection = Schema::getConnection();
5556
if ($currentDBConnection !== $this->dynamicConnectionName) {
56-
Schema::connection($this->dynamicConnectionName);
57+
$connection = Schema::connection($this->dynamicConnectionName)->getConnection();
5758
}
5859

59-
if (! Schema::hasTable($this->dynamicTableName)) {
60+
if (! $connection->getSchemaBuilder()->hasTable($this->dynamicTableName)) {
6061
throw DynamicModelException::tableDoesNotExist($this->dynamicTableName);
6162
}
6263

63-
// get primary key, incrementing and key type
64-
$connection = Schema::getConnection();
65-
6664
$table = $connection->getDoctrineSchemaManager()->listTableDetails($this->dynamicTableName);
6765

6866
if (! $primaryKey = $table->getPrimaryKey()) {

0 commit comments

Comments
 (0)