This commit is contained in:
2024-12-13 15:14:13 +08:00
parent 42af2e8bf9
commit 5b4a6b9caa
+5 -3
View File
@@ -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();