mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 23:22:48 +08:00
查询范围支持静态调用
This commit is contained in:
@@ -1812,16 +1812,27 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function __callStatic($method, $params)
|
public static function __callStatic($method, $args)
|
||||||
{
|
{
|
||||||
|
$model = new static();
|
||||||
|
|
||||||
if (isset(static::$db)) {
|
if (isset(static::$db)) {
|
||||||
$query = static::$db;
|
$query = static::$db;
|
||||||
static::$db = null;
|
static::$db = null;
|
||||||
} else {
|
} else {
|
||||||
$query = (new static())->db();
|
$query = $model->db();
|
||||||
}
|
}
|
||||||
|
|
||||||
return call_user_func_array([$query, $method], $params);
|
if (method_exists($model, 'scope' . $method)) {
|
||||||
|
// 动态调用命名范围
|
||||||
|
$method = 'scope' . $method;
|
||||||
|
array_unshift($args, $query);
|
||||||
|
|
||||||
|
call_user_func_array([$model, $method], $args);
|
||||||
|
return $query;
|
||||||
|
} else {
|
||||||
|
return call_user_func_array([$query, $method], $args);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user