From eaa0afc54e65e73067f0b13bc9b86d23405d4590 Mon Sep 17 00:00:00 2001 From: Sairahcaz Date: Mon, 3 Apr 2023 23:20:26 +0200 Subject: [PATCH] use $this->table in bindsDynamically --- src/DynamicModelBinding.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/DynamicModelBinding.php b/src/DynamicModelBinding.php index 3c10c45..747ad39 100644 --- a/src/DynamicModelBinding.php +++ b/src/DynamicModelBinding.php @@ -27,24 +27,24 @@ public function bindDynamically(): void $this->setConnection(self::$dynamicDBConnection); } - if (! Schema::hasTable(self::$dynamicTableName)) { - throw DynamicModelException::tableDoesNotExist(self::$dynamicTableName); - } - // set the table for the dynamic model $this->setTable(self::$dynamicTableName); + if (! Schema::hasTable($this->table)) { + throw DynamicModelException::tableDoesNotExist($this->table); + } + // apply primary key, incrementing and key type $connection = Schema::getConnection(); - $table = $connection->getDoctrineSchemaManager()->listTableDetails(self::$dynamicTableName); + $table = $connection->getDoctrineSchemaManager()->listTableDetails($this->table); if (! $primaryKey = $table->getPrimaryKey()) { throw DynamicModelException::primaryKeyDoesNotExist(); } $primaryKeyName = $primaryKey->getColumns()[0]; - $primaryColumn = $connection->getDoctrineColumn(self::$dynamicTableName, $primaryKeyName); + $primaryColumn = $connection->getDoctrineColumn($this->table, $primaryKeyName); $this->primaryKey = $primaryColumn->getName(); $this->incrementing = $primaryColumn->getAutoincrement();