From 08d92a2b814e89dc097a8aec4576daa07d39e8b8 Mon Sep 17 00:00:00 2001 From: kj Date: Mon, 1 Aug 2022 08:27:49 -0400 Subject: [PATCH] Allow usage of bool types on the ORM. --- src/Libs/Model.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Libs/Model.php b/src/Libs/Model.php index ce454ea..32b70f6 100644 --- a/src/Libs/Model.php +++ b/src/Libs/Model.php @@ -236,20 +236,20 @@ class Model { $properties = $reflection->getProperties(ReflectionProperty::IS_PUBLIC); $result = []; - foreach($properties as $property) { - $att = $property->name; - $result[$att] = isset($this->$att) - ? $this->$att : null; - } + foreach($properties as $property) + $result[$property->name] = isset($this->{$property->name}) + ? $this->{$property->name} : null; - foreach (static::$ignoreSave as $del) { + foreach (static::$ignoreSave as $del) unset($result[$del]); - } - foreach (static::$forceSave as $value) { + foreach (static::$forceSave as $value) $result[$value] = isset($this->$value) ? $this->$value: null; - } + + foreach ($result as $i => $property) + if (gettype($property) == 'boolean') + $result[$i] = $property ? '1' : '0'; return $result; }