Why?
Most applications require charts or reports to be generated. Doing this over again, and again can be a painful process. For this reason I've created a fluent Laravel package to solve this problem.
This package is heavily inspired by laravel-trend and exhibits for the biggest part exactly the same API for creating trends, however it operates on collections instead of models.
Requirements
PHP 8.0+ and Composer 2.0+ installed.
Installation & Setup
You can install this package with composer using the following command:
composer require jk-oster/laravel-collection-trend
Usage
To generate a trend for your collection of items, import the JkOster\CollectionTrend\CollectionTrend
class and pass along a collectable.
Example:
// Totals per month
$trend = CollectionTrend::make($collectable)
->between(
start: now()->startOfYear(),
end: now()->endOfYear(),
)
->perMonth()
->count();
Compatibility with Flowframe/Laravel-Trend API
The interface of the package is to the biggest part compatible with the Laravel-Trend package. You only need to exchange the Trend::model($model)
calls with CollectionTrend::make($collectable)
.
License
The MIT License (MIT). Please see License File for more information.
Credits
Thanks to the creators of flowframe/laravel-trend for inspiration.