Models Resources

Metrics

On the resource model index page, you can display information blocks with statistics - metrics.To do this, in the metrics() method, return an array from ValueMetric.

namespace App\MoonShine\Resources;
 
use App\Models\Post;
use MoonShine\Metrics\ValueMetric;
use MoonShine\Resources\ModelResource;
 
class PostResource extends ModelResource
{
protected string $model = Post::class;
 
protected string $title = 'Posts';
 
//...
 
public function metrics(): array
{
return [
ValueMetric::make('Articles')
->value(Post::count()),
];
}
 
//...
}

metrics metrics_dark

For more detailed information, please refer to the sections Donut Chart, Line Chart and Value.