I am trying to make a "dynamic" custom blade directive which fails because it receives the variable name and not the float. (latest laravel version)
I wanted to extend that one:
Blade::directive('money', function ($money) {
return "<?php echo number_format($money, 2, ',', ''); ?>";
});
with an if statement if (str_ends_with($money, "00")) ...
which will of cause not work, what I found out.
Is there any other way to fullfill this task?
12.3400 should be displayed as 12,34
12.3401 should be displayed as 12,3401
if there is no other solution: for the moment i am using a blade component
@props(['money'])
@if (str_ends_with($money, '00'))
{{ number_format($money, 2, ',', '') }}
@else
{{ number_format($money, 4, ',', '') }}
@endif