If i count my User::class model, the metrics work, but when i change it to another model the metric shows
" 0 No Data "
<?php
namespace App\Nova\Metrics;
use App\Kunde;
use Illuminate\Http\Request;
use Laravel\Nova\Metrics\Value;
class TotalKunden extends Value
{
/**
* Calculate the value of the metric.
*
*
public function calculate()
{
return $this->result(Kunde::count());
}
*
*@param \Illuminate\Http\Request $request
*@return mixed
*/
public function calculate(Request $request)
{
return $this->count($request, Kunde::class);
}
/**
* Get the ranges available for the metric.
**/
public function ranges()
{
return [
30 => '30 Tage',
60 => '60 Tage',
365 => '1 Jahr',
'MTD' => 'Seit Monatsbeginn',
'QTD' => 'Seit Quartalbeginn',
'YTD' => 'Seit Jahresanfang',
];
}
}
my model is referenced in the resource
with:
public static $model = 'App\Kunde';
and there is no error in the logs
only this works,
public function calculate()
{
return $this->result(Kunde::count());
}
but then the ranges are not working.
maybe someone has the same problem.. so the answer is:
metrics query is looking for the created_at column in the DB, so it must have an date
the metrics query is like this..
SELECT count(`id`) as aggregate FROM `Objects` WHERE `created_at` between '2018-11-05 12:51:22' and '2018-12-05 12:51:22' and `Objects`.`deleted_at` IS NULL
:)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.