使用 Laravel Nova 显示指标趋势时出现问题 - 参数太少
Issue displaying Metrics Trend with Laravel Nova - Too few arguments
所以我尝试向资源添加新的指标趋势,但总是收到以下错误:
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)
我正在尝试从数据库 table 'reports' 中的列 'ph_value' 接收数据 'reports'。
<?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
class 而不是 Nova resource
class.
将以下使用语句 use App\Nova\Report
更新为 use App\Report
我有同样的问题,只需更改使用 App\Nova\Report;使用 App\Report;一切都会好起来的。来自 php 的建议 storm so weird xD
所以我尝试向资源添加新的指标趋势,但总是收到以下错误:
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)
我正在尝试从数据库 table 'reports' 中的列 'ph_value' 接收数据 'reports'。
<?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
class 而不是 Nova resource
class.
将以下使用语句 use App\Nova\Report
更新为 use App\Report
我有同样的问题,只需更改使用 App\Nova\Report;使用 App\Report;一切都会好起来的。来自 php 的建议 storm so weird xD