Calculate value, trend, progress, and partition metrics from any Eloquent query.
roundly-consulting/metrics-for-laravel is a Laravel package for calculate value, trend, progress, and partition metrics from any eloquent query..
It currently has 5 GitHub stars and 20 downloads on Packagist (latest version 1.1.2).
Install it with composer require roundly-consulting/metrics-for-laravel.
Discover more Laravel packages by roundly-consulting
or browse all Laravel packages to compare alternatives.
Last updated
Turn any Eloquent query into a ready-to-render dashboard metric: a single value with period-over-period change, a time series for charts, progress against a target, or a partitioned breakdown. Date ranges, timezones, aggregation, caching and formatting are handled for you, and the result comes back as clean JSON for any front-end — no admin panel required.
Requires PHP 8.4 and Laravel 12 or 13.
composer require roundly-consulting/metrics-for-laravel
Build a metric inline from any query — toArray() is the JSON-ready envelope:
use App\Models\Order;
use App\Models\User;
use RoundlyConsulting\Metrics\Enums\Period;
use RoundlyConsulting\Metrics\Facades\Metrics;
Metrics::value()->count(User::query())
->range(Period::Today)
->withChangeAgainstPreviousPeriod()
->toArray();
Metrics::trend()->count(User::query(), 'created_at')->daily()->range(Period::MonthToDate)->toArray();
Metrics::progress()->sum(Order::query(), 'total')->target(10000)->range(Period::MonthToDate)->toArray();
Metrics::partition()->count(User::query(), 'plan')->limit(5)->toArray();
Or read the typed result in PHP:
$revenue = Metrics::value()->sum(Order::query(), 'total')->range(Period::ThisMonth)->result();
$revenue->value(); // 15230.0
Register metrics under keys and return a whole dashboard from one endpoint:
Metrics::register('signups', fn () => Metrics::value()->name('Sign-ups')->count(User::query()));
Metrics::register('revenue', fn () => Metrics::progress()->name('Revenue')->sum(Order::query(), 'total')->target(10000));
return Metrics::dashboard(['signups', 'revenue'])->range(Period::ThisMonth); // Responsable: JSON
The full documentation — configuration, every feature and its API, and testing — lives on our website: roundly-consulting.com/open-source/docs/metrics-for-laravel
Release notes are in CHANGELOG.md. To contribute, see the contributing guide.
This package is free and open source, built and maintained by Roundly Consulting. If it saves you time, please consider supporting our open-source work — a one-time donation, a monthly pledge on Patreon or a crypto donation helps fund maintenance, new features and new packages.
The MIT License (MIT). Please see License File for more information.