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