PHPackages                             beranidigital/laravel-trend - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. beranidigital/laravel-trend

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

beranidigital/laravel-trend
===========================

Easily generate model trends. Now with more intervals

0.2.2(1y ago)130MITPHPPHP ^8.2

Since May 17Pushed 1y agoCompare

[ Source](https://github.com/beranidigital/laravel-trend)[ Packagist](https://packagist.org/packages/beranidigital/laravel-trend)[ Docs](https://github.com/flowframe/laravel-trend)[ GitHub Sponsors](https://github.com/larsklopstra)[ RSS](/packages/beranidigital-laravel-trend/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (9)Versions (4)Used By (0)

Laravel Trend
=============

[](#laravel-trend)

Generate trends for your models. Easily generate charts or reports.

Why?
----

[](#why)

Most applications require charts or reports to be generated. Doing this over again, and again can be a painful process. That's why we've created a fluent Laravel package to solve this problem.

You can aggregate average, min, max, and totals per minute, hour, day, month, and year.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require beranidigital/laravel-trend
```

Usage
-----

[](#usage)

To generate a trend for your model, import the `Flowframe\Trend\Trend` class and pass along a model or query.

Example:

```
// Totals per month
$trend = Trend::model(User::class)
    ->between(
        start: now()->startOfYear(),
        end: now()->endOfYear(),
    )
    ->perMonth()
    ->count();

// Average user weight where name starts with a over a span of 11 years, results are grouped per year
$trend = Trend::query(User::where('name', 'like', 'a%'))
    ->between(
        start: now()->startOfYear()->subYears(10),
        end: now()->endOfYear(),
    )
    ->perYear()
    ->average('weight');
```

If you don't specify a date range, the package will automatically determine the range based on the interval you've chosen.

Starting a trend
----------------

[](#starting-a-trend)

You must either start a trend using `::model()` or `::query()`. The difference between the two is that using `::query()` allows you to add additional filters, just like you're used to using eloquent. Using `::model()` will just consume it as it is.

```
// Model
Trend::model(Order::class)
    ->between(...)
    ->perDay()
    ->count();

// More specific order query
Trend::query(
    Order::query()
        ->hasBeenPaid()
        ->hasBeenShipped()
)
    ->between(...)
    ->perDay()
    ->count();
```

Interval
--------

[](#interval)

You can use the following aggregates intervals:

- `perMinute()`
- `perHour()`
- `perDay()`
- `perWeek()`
- `perMonth()`
- `perYear()`

Aggregates
----------

[](#aggregates)

You can use the following aggregates:

- `sum('column')`
- `average('column')`
- `max('column')`
- `min('column')`
- `count('*')`

Date Column
-----------

[](#date-column)

By default, laravel-trend assumes that the model on which the operation is being performed has a `created_at` date column. If your model uses a different column name for the date or you want to use a different one, you should specify it using the `dateColumn(string $column)` method.

Example:

```
Trend::model(Order::class)
    ->dateColumn('custom_date_column')
    ->between(...)
    ->perDay()
    ->count();
```

Override Date Format
--------------------

[](#override-date-format)

By default, laravel-trend uses the `Y-m-d H:i:s` format for the date column. If you want to use a different format, you should specify it using the `Trend::$carbonFormats` property.

Example:

```
Flowframe\Trend\Trend::$carbonFormats['minute'] = 'Y-m-d H:i:00';
Flowframe\Trend\Trend::$carbonFormats['hour'] = 'Y-m-d H:00:00';
Flowframe\Trend\Trend::$carbonFormats['day'] = 'd-M-Y';
Flowframe\Trend\Trend::$carbonFormats['week'] = 'W/Y';
Flowframe\Trend\Trend::$carbonFormats['month'] = 'Y-m';
Flowframe\Trend\Trend::$carbonFormats['year'] = 'Y';
```

This allows you to work with models that have custom date column names or when you want to analyze data based on a different date column.

Drivers
-------

[](#drivers)

We currently support three drivers:

- MySQL
- MariaDB
- SQLite
- PostgreSQL

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Lars Klopstra](https://github.com/flowframe)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 64.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~6 days

Total

2

Last Release

719d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/723b277df7f51911151449e126c6527b11090326fe61533900cea8a21d76cdee?d=identicon)[Ticlext-Altihaf](/maintainers/Ticlext-Altihaf)

---

Top Contributors

[![Ticlext-Altihaf](https://avatars.githubusercontent.com/u/77704356?v=4)](https://github.com/Ticlext-Altihaf "Ticlext-Altihaf (36 commits)")[![Larsklopstra](https://avatars.githubusercontent.com/u/25669876?v=4)](https://github.com/Larsklopstra "Larsklopstra (8 commits)")[![devatreides](https://avatars.githubusercontent.com/u/18440704?v=4)](https://github.com/devatreides "devatreides (3 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (2 commits)")[![sairiz](https://avatars.githubusercontent.com/u/1634949?v=4)](https://github.com/sairiz "sairiz (2 commits)")[![ymigval](https://avatars.githubusercontent.com/u/68402880?v=4)](https://github.com/ymigval "ymigval (1 commits)")[![mwikala](https://avatars.githubusercontent.com/u/39342367?v=4)](https://github.com/mwikala "mwikala (1 commits)")[![pktharindu](https://avatars.githubusercontent.com/u/23132672?v=4)](https://github.com/pktharindu "pktharindu (1 commits)")[![raymon-roos](https://avatars.githubusercontent.com/u/38888470?v=4)](https://github.com/raymon-roos "raymon-roos (1 commits)")[![wit3](https://avatars.githubusercontent.com/u/5450259?v=4)](https://github.com/wit3 "wit3 (1 commits)")

---

Tags

filamentphplaravellaravel-packagelaravelFlowframelaravel-trend

###  Code Quality

TestsPest

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/beranidigital-laravel-trend/health.svg)

```
[![Health](https://phpackages.com/badges/beranidigital-laravel-trend/health.svg)](https://phpackages.com/packages/beranidigital-laravel-trend)
```

###  Alternatives

[flowframe/laravel-trend

Easily generate model trends

1.1k3.2M33](/packages/flowframe-laravel-trend)[spatie/laravel-data

Create unified resources and data transfer objects

1.7k28.9M627](/packages/spatie-laravel-data)[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[ralphjsmit/livewire-urls

Get the previous and current url in Livewire.

82270.3k4](/packages/ralphjsmit-livewire-urls)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
