moirei / eloquent-metrics
Retrieve metric data on Eloquent Models for analytics.
0.4.0
2026-03-21 09:35 UTC
Requires
- php: ^8.2
- cakephp/chronos: ^3.0
- illuminate/database: ^10.0|^11.0|^12.0
- illuminate/support: ^10.0|^11.0|^12.0
- laravel/helpers: ^1.7
Requires (Dev)
- orchestra/testbench: ^9.0
- pestphp/pest: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
- phpunit/phpunit: ^11.0
README
All documentation is available at the documentation site.
Example
... use MOIREI\Metrics\Trend; $metrics = Trend::make() ->name('Order Sales') ->period('week') // sample a week ago intil now ->add('previous-period') // add a comparison period ->sumByDays(\App\Models\Order::class, 'total');
Example with moirei/hogql
... $query = HogQl::eloquent()->where('event', '$pageview'); $metrics = Trend::make() ->name('Page views') ->period('week') ->add('previous-period') ->sumByDays($query);
Installation
composer require moirei/eloquent-metrics
Changelog
Please see CHANGELOG.
Credits
License
The MIT License (MIT). Please see License File for more information.