nova-issues
nova-issues copied to clipboard
Trend Metric appears outside of its card (and impossible to click on its filter)
- Laravel Version: 11.10
- Nova Version: 4.34.3
- PHP Version: 8.3
- Database Driver & Version: PostgreSQL 16.3 (Debian 16.3-1.pgdg120+1)
- Operating System and Version : MacOs Ventura 13.6.7 (locahost)
- Browser type and version: Chrome
Description:
The trend below is displayed in a dashboard. As you can see, the trend is displayed outside of its card. The filter for this trend is blocked. I tried clearing my application and browser caches but that doesn't change anything.
Detailed steps to reproduce the issue on a fresh Nova installation:
CostsPerDay Metric
<?php
namespace App\Nova\Metrics;
use App\Models\Cost;
use Laravel\Nova\Http\Requests\NovaRequest;
use Laravel\Nova\Metrics\Trend;
class CostsPerDay extends Trend
{
public function name()
{
return 'Coûts par jour';
}
/**
* Calculate the value of the metric.
*
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
* @return mixed
*/
public function calculate(NovaRequest $request)
{
return $this->countByDays($request, Cost::class)->showLatestValue()
->format(function ($value) {
return round($value, 2);
});
}
/**
* Get the ranges available for the metric.
*
* @return array
*/
public function ranges()
{
return [
30 => '30 Days',
60 => '60 Days',
90 => '90 Days',
];
}
/**
* Get the URI key for the metric.
*
* @return string
*/
public function uriKey()
{
return 'costs-per-day';
}
}
My model "Cost"
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Cost extends Model
{
use HasFactory;
protected $table = 'accounting.cost';
protected $fillable = [
'category_id',
'external_id',
'external_table_name',
'name',
'cost',
];
protected $dates = [
'created_at',
'updated_at',
'deleted_at'
];
public function costCategory()
{
return $this->belongsTo(CostCategory::class, 'category_id');
}
}