diff --git a/src/Libs/Model.php b/src/Libs/Model.php index 1861ebe..bfb93dc 100644 --- a/src/Libs/Model.php +++ b/src/Libs/Model.php @@ -1098,8 +1098,18 @@ class Model public static function search(string $search, ?array $in = null): static { if ($in == null) { - $className = get_called_class(); - $in = array_keys((new $className())->getVars()); + $in = []; + $reflection = new \ReflectionClass(get_called_class()); + + foreach ($reflection->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) { + if (!in_array($property->getName(), static::$dbIgnoreSave)) { + $in[] = static::camelCaseToSnakeCase($property->getName()); + } + } + } + + if (empty($in)) { + return new static(); } $search = static::bind($search);