gpt4 book ai didi

php - 使用 Laravel Nova 显示指标趋势的问题 - 参数太少

转载 作者:行者123 更新时间:2023-12-05 01:40:52 25 4
gpt4 key购买 nike

所以我尝试向资源添加新的指标趋势,但总是收到以下错误:

Too few arguments to function Laravel\Nova\Resource::__construct(), 0 passed in /crm/nova/src/Metrics/Trend.php on line 116 and exactly 1 expected {"userId":1,"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Too few arguments to function Laravel\\Nova\\Resource::__construct(), 0 passed in crm/nova/src/Metrics/Trend.php on line 116 and exactly 1 expected at /crm/nova/src/Resource.php:108)

我正在尝试从数据库表“reports”中的“ph_value”列接收数据。

<?php

namespace App\Nova\Metrics;

use Illuminate\Http\Request;
use Laravel\Nova\Metrics\Trend;
use App\Nova\Report;

class ph extends Trend
{
/**
* Calculate the value of the metric.
*
* @param \Illuminate\Http\Request $request
* @return mixed
*/
public function calculate(Request $request)
{
return $this->countByDays($request, Report::class, 'ph_value');
}

/**
* Get the ranges available for the metric.
*
* @return array
*/
public function ranges()
{
return [
30 => '30 Days',
60 => '60 Days',
90 => '90 Days',
];
}

/**
* Determine for how many minutes the metric should be cached.
*
* @return \DateTimeInterface|\DateInterval|float|int
*/
public function cacheFor()
{
// return now()->addMinutes(5);
}

/**
* Get the URI key for the metric.
*
* @return string
*/
public function uriKey()
{
return 'ph';
}
}

当然包括卡片。

public function cards(Request $request)
{
return [
new Metrics\Ph,
];
}

趋势指标会不断加载,就像它无法检索数据一样。

最佳答案

countByDays 函数的第二个参数是一个 model 类而不是 Nova resource 类。

更新以下使用语句 use App\Nova\Reportuse App\Report

关于php - 使用 Laravel Nova 显示指标趋势的问题 - 参数太少,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55657024/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com