Unable to set carbon null date in Laravel 5

I have a column dateTimein my migrations that Laravel accepts as Carbon. The name of the column terminado_emand is NULL.

I set the value Carbonusing my model.

Now that I want to install terminado_emin null:

public function reiniciar()
{
    $this->terminado_em = null;
    ...
}

I get an error

InvalidArgumentException in Carbon.php line 425: Data missing

How to set a property Carbonto null if it is already set to a value Carbon?

+4
source share
1 answer

I could not set the Carbon property of the object directly to access the property $this->terminado_em, but access to the property of the general model, attributesit worked.

$this->attributes['terminado_em'] = null;
+1

Source: https://habr.com/ru/post/1624082/


All Articles