moirei/eloquent-metrics

Retrieve metric data on Eloquent Models for analytics.

0.3.2 2024-08-05 12:22 UTC

This package is auto-updated.

Last update: 2025-03-05 13:54:54 UTC


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.