I would like to know how to format monetary values in Laravel. Is there a package or method that is for the framework ?
{{ $lst->vl_valor_tot_contrato }}
is displayed with monetary formatting like this: (R$ 105.273,54)
I would like to know how to format monetary values in Laravel. Is there a package or method that is for the framework ?
{{ $lst->vl_valor_tot_contrato }}
is displayed with monetary formatting like this: (R$ 105.273,54)
To do this on the server side with PHP use the money_format
function.
For example:
{{ money_format('%n', $lst->vl_valor_tot_contrato ) }}
Do not forget to set the locale correctly in PHP.
setlocale(LC_MONETARY, 'pt_BR');
If the money_format
function is not available in your installation, you can also get the result with the function number_format
{{ 'R$ '.number_format($lst->vl_valor_tot_contrato, 2, ',', '.') }}
Fonts :