如何使用 Laravel Collective 在 Blade 中使用 Laravel Directive Currency 格式

问题描述

我有一些这样的文本框 {{{ Form::number('amount',$cash->amount,array('class'=>'form-control')) }}} 但我想以货币格式显示文本框

我尝试像这样制作 Laravel 指令 Blade::directive('convert',function ($money) { return "<?PHP echo 'Rp.' . number_format($money,2); ?>"; });

当我在文本框 {{{ Form::number('amount',@convert($cash->amount),array('class'=>'form-control')) }}} 中尝试返回解析错误时出现意外的“<label>@convert(11223344)</label> 这就是工作。

谢谢

解决方法

我认为这就是您所需要的:

{{{ Form::number('amount','Rp.' . number_format($cash->amount,2),array('class'=>'form-control')) }}}