1
I’m using Laravel + Postgres and I’m hoping to receive a decimal value, and in Migration I did so: $table->decimal('valor', 10, 2);
When I get this amount, I get something like, $1,500.99 Before sending to the bank, I made a mutator that takes anything that is NOT a number, but when it arrives at the postgres it arrives like this: 150099.00 . That is, Added two zeros at the end.
Does anyone know how I can solve this problem?
Maybe your mutator is removing characters that are not numbers leaving it as a complete integer
– Darlei Fernando Zillmer
You can use https://www.php.net/manual/en/function.number-format.php
– SylvioT
put the mutator in the question please to check what you are doing wrong
– novic
I am calling this Function in the mutator: Function parse_money($number) { $number = preg_replace('/[ 0-9]+/', '', $number); Return number_format($number, 2, ',', '.'); }
– Brigadeiro Programador
first I’m taking out the R$ that arrives, and then formatting but it hasn’t worked yet
– Brigadeiro Programador