From 9723900b893a4b5bf2271af5789e24b7e9c03456 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Mon, 29 Sep 2025 10:23:22 +0100 Subject: [PATCH] =?UTF-8?q?Revert=20"[11.x]=20Fixes=20incorrectly=20serial?= =?UTF-8?q?izing=20virtual=20properties=20(backport)=20(#=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 9c80cf4bb6b8597b7877620b86ef73b1eb6f14e4. --- src/Illuminate/Database/Eloquent/Model.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/Illuminate/Database/Eloquent/Model.php b/src/Illuminate/Database/Eloquent/Model.php index 2d54b2c82e5e..44878f7bf880 100644 --- a/src/Illuminate/Database/Eloquent/Model.php +++ b/src/Illuminate/Database/Eloquent/Model.php @@ -2421,15 +2421,7 @@ public function __sleep() $this->classCastCache = []; $this->attributeCastCache = []; - // When serializing the model, we may accidentally catch up some virtual properties. - // We will cast the model to a native array to skip them and then apply a function - // to clean each of the property names which is miles faster than using a regex. - return array_map( - fn ($key) => $key[0] === "\0" - ? substr($key, strpos($key, "\0", 1) + 1) - : $key, - array_keys((array) $this) - ); + return array_keys(get_object_vars($this)); } /**