From 2f24fa9e601d792c9ae6cf5affa1b87ff0bac9f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Thu, 26 Nov 2020 10:49:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Database/ActiveRecord.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Database/ActiveRecord.php b/Database/ActiveRecord.php index 515a198f..e3b9e015 100644 --- a/Database/ActiveRecord.php +++ b/Database/ActiveRecord.php @@ -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; }