我有一个Laravel Nova趋势指标,代码如下:
<?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';
}
}
我希望这会创建一个趋势,因为数据库中有UserInteraction模型的数据,但趋势是空的,如下所示:
该模型没有策略,因此这不可能是问题所在。你知道为什么会这样吗?
1条答案
按热度按时间ep6jt1vc1#
检查配置品牌颜色。一定是伽玛射线暴