From 189b216b9452e42da9c11fea94d7a209fb14c062 Mon Sep 17 00:00:00 2001 From: Sairahcaz Date: Fri, 14 Apr 2023 10:38:40 +0200 Subject: [PATCH] fix connection issue --- src/DynamicModelFactory.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/DynamicModelFactory.php b/src/DynamicModelFactory.php index 36b5730..c494b05 100644 --- a/src/DynamicModelFactory.php +++ b/src/DynamicModelFactory.php @@ -52,17 +52,15 @@ private function getDynamicTableValues(): array $currentDBConnection = Schema::getConnection()->getName(); + $connection = Schema::getConnection(); if ($currentDBConnection !== $this->dynamicConnectionName) { - Schema::connection($this->dynamicConnectionName); + $connection = Schema::connection($this->dynamicConnectionName)->getConnection(); } - if (! Schema::hasTable($this->dynamicTableName)) { + if (! $connection->getSchemaBuilder()->hasTable($this->dynamicTableName)) { throw DynamicModelException::tableDoesNotExist($this->dynamicTableName); } - // get primary key, incrementing and key type - $connection = Schema::getConnection(); - $table = $connection->getDoctrineSchemaManager()->listTableDetails($this->dynamicTableName); if (! $primaryKey = $table->getPrimaryKey()) {