Skip to content

Instantly share code, notes, and snippets.

@czemu

czemu/NewRecipes.php Secret

Last active Mar 4, 2020
Embed
What would you like to do?
<?php
namespace App\Nova\Metrics;
use App\Recipe;
use Illuminate\Http\Request;
use Laravel\Nova\Metrics\Trend;
class NewRecipes extends Trend
{
/**
* Calculate the value of the metric.
*
* @param \Illuminate\Http\Request $request
* @return mixed
*/
public function calculate(Request $request)
{
return $this->countByDays($request, Recipe::class)->showLatestValue();
}
/**
* Get the ranges available for the metric.
*
* @return array
*/
public function ranges()
{
return [
30 => '30 Days',
60 => '60 Days',
90 => '90 Days'
];
}
/**
* Get the URI key for the metric.
*
* @return string
*/
public function uriKey()
{
return 'new-recipes';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment