From 5b4a6b9caa73333d46553394d9f6a66116334b9f Mon Sep 17 00:00:00 2001 From: whwyy Date: Fri, 13 Dec 2024 15:14:13 +0800 Subject: [PATCH] eee --- Traits/QueryTrait.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Traits/QueryTrait.php b/Traits/QueryTrait.php index 0f8bcf8..08b9bdc 100644 --- a/Traits/QueryTrait.php +++ b/Traits/QueryTrait.php @@ -434,13 +434,15 @@ abstract class QueryTrait extends Component implements ActiveQueryInterface, ISq /** - * @param string|Closure $tableName + * @param string|Closure|Query $tableName * * @return $this */ - public function from(string|Closure $tableName): static + public function from(string|Closure|Query $tableName): static { - if ($tableName instanceof Closure) { + if ($tableName instanceof Query) { + $this->from = '(' . $tableName->build() . ')'; + } else if ($tableName instanceof Closure) { $this->from = '(' . $this->makeClosureFunction($tableName) . ')'; } else if (class_exists($tableName)) { $this->from = (new $tableName)->getTable();