-
Description:After trying many ways to format the Metrics values, I can't see the decimals of any value. If I have a value of 1.1, only 1 is shown. Detailed steps to reproduce the issue on a fresh Nova installation:
<?php
namespace App\Nova\Metrics;
use App\Models\Deposit;
use Laravel\Nova\Http\Requests\NovaRequest;
use Laravel\Nova\Metrics\Trend;
class DepositPerDay extends Trend
{
/**
* Calculate the value of the metric.
*
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
* @return mixed
*/
public function calculate(NovaRequest $request)
{
return $this->sumByDays(
$request,
Deposit::class,
'amount'
)->format('0.000')->showSumValue();
}
}
|
Beta Was this translation helpful? Give feedback.
Answered by
crynobone
May 17, 2022
Replies: 1 comment 1 reply
-
|
You can add return $this->precision(2)
->sumByDays(
$request,
Deposit::class,
'amount'
)
->format('0.000')
->showSumValue(); |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
crynobone
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

You can add
precision($precision = 0, $mode = PHP_ROUND_HALF_UP)to configure how rounding work with the results.