使用Laravel Nova显示度量标准趋势的问题 - 参数太少

问题描述 投票:1回答:1

因此,我正在尝试向资源添加新的度量标准趋势,但始终收到以下错误:

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,
        ];
    }

趋势指标只是不断加载,因为它不可用于检索数据。

php laravel laravel-nova
1个回答
1
投票

qazxsw poi函数第二个参数是qazxsw poi类而不是Nova countByDays类。

将使用声明model更新为resource

© www.soinside.com 2019 - 2024. All rights reserved.