mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 20:52:48 +08:00
调试Model类append方法的追加顺序
This commit is contained in:
@@ -478,11 +478,6 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
||||
public function toArray($allow = [])
|
||||
{
|
||||
$item = [];
|
||||
if (!empty($this->append)) {
|
||||
foreach ($this->append as $name) {
|
||||
$item[$name] = $this->getAttr($name);
|
||||
}
|
||||
}
|
||||
if (empty($allow)) {
|
||||
$allow = array_keys($this->data);
|
||||
}
|
||||
@@ -508,6 +503,12 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
||||
$item[$key] = $this->getAttr($key);
|
||||
}
|
||||
}
|
||||
// 追加属性(必须定义获取器)
|
||||
if (!empty($this->append)) {
|
||||
foreach ($this->append as $name) {
|
||||
$item[$name] = $this->getAttr($name);
|
||||
}
|
||||
}
|
||||
return !empty($item) ? $item : [];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user