Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

cverster's avatar

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:

Empty Nova Trend

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

0 likes
0 replies

Please or to participate in this conversation.