I have a Laravel mutator to handle a field, but if the field is empty it does not save the default value in the database.
MODEL
/// PROMOÇÃO TROCA VIRGULA POR PONTO
public function setPromocaoAttribute($value)
{
$value==null ? '0.00' : $this->attributes['promocao'] = str_replace(",", ".", $value);
}
Neither preset nor even bank works
In the database, you have to:
'promotion' decimal (8,2) NOT-NULL and also Default ('0.00')
I needed it to be saved as null, or as 0.00 but it is difficult kkk apparently only want to save if the value is greater than 0