0
I have a Laravel mutator to treat a field, but if the field comes empty it does not save the default value in the bank.
MODEL
/// PROMOÇÃO TROCA VIRGULA POR PONTO
public function setPromocaoAttribute($value)
{
$value==null ? '0.00' : $this->attributes['promocao'] = str_replace(",", ".", $value);
}
neither preset before nor even in the bank works
in the bank is OBS:(also already tried to leave NULL in the bank, even so does not update the field)
'promocao' decimal(8,2) NOT-NULL and also Default ('0.00')
I needed it to be safe as null, or 0.00 but it’s hard kkk apparently only wants to save if the value is greater than 0
Ball show bro! worked perfectly, yes it is php 7. Thank you.
– MichaelCosta