Fix Blade money directive

This commit is contained in:
Jérémy Munsch 2024-07-01 16:02:15 +02:00
parent a13428ca38
commit c51aabbc33
No known key found for this signature in database
GPG key ID: 18361AF3BFEC0FEC
2 changed files with 4 additions and 3 deletions

View file

@ -47,8 +47,9 @@ class ViewServiceProvider extends ServiceProvider
$view->with('viewName', $view->getName());
});
Blade::directive('money', function (string|int $amount) {
return "app('phpMoneyFormatter')->format(new Money({$amount}, app('phpMoneyCurrency')))";
Blade::directive('money', function (string $amountVariable) {
// phpcs:ignore Generic.Files.LineLength.TooLong
return "<?php echo e(app('phpMoneyFormatter')->format(new Money({$amountVariable}, app('phpMoneyCurrency')))); ?>";
});
// * Inject menuNodeList

View file

@ -12,7 +12,7 @@
])>{{ $line2 }}</div>
</div>
@if (!empty($promoAmount))
<span class="promo-badge">{{ @money($promoAmount) }}</span>
<span class="promo-badge">@money($promoAmount)</span>
@endif
@if (!empty($membersAmount))
<span class="promo-members">{{ number_format($membersAmount, 0, ',', ' ') }}&nbsp;{{ __('membres') }}</span>