From 11141a0eee989b1d38aed4856250b989e4d92d8c Mon Sep 17 00:00:00 2001 From: kj Date: Sat, 25 Mar 2023 12:27:33 -0400 Subject: [PATCH] Allow send string to setNull method. --- src/Libs/Model.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Libs/Model.php b/src/Libs/Model.php index 3ea40e7..46b90f6 100644 --- a/src/Libs/Model.php +++ b/src/Libs/Model.php @@ -805,13 +805,21 @@ class Model { * Permite definir como nulo el valor de un atributo. * Sólo funciona para actualizar un elemento de la BD, no para insertar. * - * @param array $atts + * @param string|array $atts + * Atributo o arreglo de atributos que se definirán como nulos. + * + * @return void */ - public function setNull(array $atts) { - foreach ($atts as $att) { - if (!in_array($att, $this->toNull)) - $this->toNull[] = $att; + public function setNull(string|array $atts): void { + if (is_array($atts)) { + foreach ($atts as $att) + if (!in_array($att, $this->toNull)) + $this->toNull[] = $att; + return; } + + if (!in_array($atts, $this->toNull)) + $this->toNull[] = $atts; } } ?>