Allow send string to setNull method.

This commit is contained in:
kj 2023-03-25 12:27:33 -04:00
parent 3c8a21161f
commit 11141a0eee
1 changed files with 13 additions and 5 deletions

View File

@ -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;
}
}
?>