Search code examples
phplaraveleloquentlaravel-nova

Laravel Nova Metrics Value format not working


I can't seem to get Nova's formatting for the Value Metrics to work. Simply nothing happens when I add the property to my return.

Any hints on what might be wrong?

$total = DB::table(hello')->sum(DB::raw('bye'));
return $this->result($total)->format("0,0");

Solution

  • You must return an object, an example:

    return (new ValueResult($total))
                ->currency('$ ')
                ->format('0,0');