From 3ca07680269ba9f0b76fc14ff18f2b4184235c41 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 27 Nov 2023 19:59:16 +0900 Subject: [PATCH] refactor: remove if condition --- system/Model.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/system/Model.php b/system/Model.php index f95ceabcedd0..34a20cb8be87 100644 --- a/system/Model.php +++ b/system/Model.php @@ -812,19 +812,16 @@ protected function objectToRawArray($object, bool $onlyChanged = true, bool $rec // Restore Entity casting setting. $object->cast($cast); - } - // Always grab the primary key otherwise updates will fail. - if ( - $object instanceof Entity - && ( + // Always grab the primary key otherwise updates will fail. + if ( ! empty($properties) && ! empty($this->primaryKey) && ! in_array($this->primaryKey, $properties, true) && ! empty($primaryKey) - ) - ) { - $properties[$this->primaryKey] = $primaryKey; + ) { + $properties[$this->primaryKey] = $primaryKey; + } } return $properties;