0

I'm trying to format an integer in Laravel Nova but nothing seems to work.

I have tried the following:

Currency::make('Price', 'price')
        ->displayUsing(function($value) {
             return number_format($value, ',');
        })
        ->hideFromDetail(),

Currency::make('Price', 'price')
        ->format('%.2n')
        ->hideFromDetail(),

It also doesn't work if I utilise the Number field.

The result is always an unformatted number like 49000000000 when it should be 49,000,000,000

What am I missing?

Marcus Christiansen
  • 2,759
  • 6
  • 38
  • 78

1 Answers1

2

Try this, maybe help you:

Text::make('Price', 'price', function () {
    return !is_null($this->price) ? number_format($this->price, 2, '.', ',') : 0;
}),
João Guilherme
  • 1,382
  • 1
  • 15
  • 27
Pace
  • 77
  • 12