toneflix-code / laravel-stats
A simple Laravel package to help you quickly get usage metrics and data from your app.
1.0.0
2024-03-19 15:07 UTC
Requires
- php: ^8.1|^8.2
- illuminate/support: ^10.0|^11.0
Requires (Dev)
- fakerphp/faker: ^1.21
- illuminate/contracts: ^10.0|^11.0
- laravel/pint: ^1.14
- orchestra/testbench: ^8.22|^9.0
- pestphp/pest: ^2.33
- pestphp/pest-plugin-laravel: ^2.3
README
A simple Laravel package to help you quickly get usage metrics and data from your app.
Installation
You can install the package via composer:
composer require toneflix-code/laravel-stats
Usage
use ToneflixCode\Stats\Ranger; use ToneflixCode\Stats\Stats; $stats = (new Stats()) ->registerMetric( modelClass: \App\Models\User::class, metric: Metric::COUNT, period: Ranger::years('created_at', 'M Y')->fromDate(now()->subYears(1))->toDate(now()->subYears(1)->addYear())->range('1 month'), aggregateField: 'id', label: 'old_users' ) ->registerMetric( modelClass: \App\Models\User::class, period: ['from' => now()->subYears(1), 'to' => now()], metric: Metric::COUNT, aggregateField: 'id', ) ->registerMetric( modelClass: new \App\Models\User(), period: ['from' => now()->subYears(1), 'to' => now()], metric: Metric::COUNT, callback: fn ($query) => $query->find(1)->posts(), aggregateField: 'id', ) ->build()
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email legacy@toneflix.com.ng instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.