This commit is contained in:
2020-11-26 10:49:59 +08:00
parent 952014f157
commit 2f24fa9e60
+11 -1
View File
@@ -288,7 +288,17 @@ class ActiveRecord extends BaseActiveRecord
if (!method_exists($this, $data)) {
return $data;
}
return ArrayAccess::toArray($this->{$data}());
$resolve = $this->{$data}();
if ($resolve instanceof Collection) {
return $resolve->toArray();
}
if ($resolve instanceof ActiveRecord) {
return $resolve->toArray();
}
if (is_object($resolve)) {
return get_object_vars($resolve);
}
return $resolve;
}