Jun 13, 2022
0
Level 6
Nova Trend Not Displaying, and I'm Using a Model not a Nova Resource
I have a Laravel Nova trend metric with the following code:
<?php
namespace App\Nova\Metrics;
use App\Models\UserInteraction;
use Laravel\Nova\Http\Requests\NovaRequest;
use Laravel\Nova\Metrics\Trend;
class InteractionsPerDay extends Trend
{
/**
* Calculate the value of the metric.
*
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
* @return mixed
*/
public function calculate(NovaRequest $request)
{
return $this->countByDays($request, UserInteraction::class);
}
/**
* Get the ranges available for the metric.
*
* @return array
*/
public function ranges()
{
return [
30 => '30 Days',
60 => '60 Days',
90 => '90 Days',
];
}
/**
* Determine the amount of time the results of the metric should be cached.
*
* @return \DateTimeInterface|\DateInterval|float|int|null
*/
public function cacheFor()
{
// return now()->addMinutes(5);
}
/**
* Get the URI key for the metric.
*
* @return string
*/
public function uriKey()
{
return 'interactions-per-day';
}
}
I would expect this to create a trend, as there is data for the UserInteraction model in the database, but the trend is empty as can be seen below:

There is no Policy for the model so that can't be the issue. Any ideas as to why this could be happening?
Please or to participate in this conversation.