PHPackages                             wsenjer/laravel-trends - 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. wsenjer/laravel-trends

ActiveLibrary

wsenjer/laravel-trends
======================

Laravel Trends provides a lightweight trending system to your application.

v0.1.3(3y ago)19MITPHPPHP ^7.2|^8.0

Since Mar 27Pushed 3y agoCompare

[ Source](https://github.com/wsenjer/laravel-trends)[ Packagist](https://packagist.org/packages/wsenjer/laravel-trends)[ RSS](/packages/wsenjer-laravel-trends/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (7)Used By (0)

[![](https://camo.githubusercontent.com/fd80d28d4ae6316ee754e2a1d0c8e1282cf87bc0ff25b4e58fbe65a19b85543f/68747470733a2f2f692e6962622e636f2f636363663734742f6c6f676f2e706e67)](https://camo.githubusercontent.com/fd80d28d4ae6316ee754e2a1d0c8e1282cf87bc0ff25b4e58fbe65a19b85543f/68747470733a2f2f692e6962622e636f2f636363663734742f6c6f676f2e706e67)

[![Total Downloads](https://camo.githubusercontent.com/32a10f6a77efc5f064a8e589baefae32dea195a8e87d1c240032f7f790865fb3/68747470733a2f2f706f7365722e707567782e6f72672f6861636b6c6162736465762f6c61726176656c2d7472656e64732f642f746f74616c)](https://packagist.org/packages/hacklabsdev/laravel-trends) [![Latest Stable Version](https://camo.githubusercontent.com/ad06d2e697176795645b9f824d80858ac7e74f81d9f7bad1fead69a6632af990/68747470733a2f2f706f7365722e707567782e6f72672f6861636b6c6162736465762f6c61726176656c2d7472656e64732f762f737461626c65)](https://packagist.org/packages/hacklabsdev/laravel-trends) [![License](https://camo.githubusercontent.com/126e08e5b45e046e65e4553617a576c2a253af03d36034f0f6600ba801b1ddf7/68747470733a2f2f706f7365722e707567782e6f72672f6861636b6c6162736465762f6c61726176656c2d7472656e64732f6c6963656e7365)](https://packagist.org/packages/hacklabsdev/laravel-trends)

Introduction
------------

[](#introduction)

Have you ever wondered how Twitter's Trending Topics works? Laravel Trends provides a lightweight trending system to your application.

Prerequisites
-------------

[](#prerequisites)

Before you install the package make sure you have queues working and running since Trends uses it to control the tendences. Refer to Laravel [official documentation](https://laravel.com/docs/master/queues#introduction "official documentation") in order to configure queues in your project.

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

[](#installation)

You may install Laravel Trends via Composer:

`$ composer require hacklabsdev/laravel-trends`

Next, publish the Trends configuration and migration files using the vendor:publish command. The configuration file will be placed in your config directory:

`$ php artisan vendor:publish --provider="Hacklabs\Trends\TrendsServiceProvider"`

And finally, you should run your database migrations:

`php artisan migrate`

How it works
------------

[](#how-it-works)

Trends allows you to create a trending system for any model you want. Let's take Twitter as an example. Everytime a hashtag is tweeted it receives 1 point of energy, but after 30 minutes this single point of energy decays 0.25 of it's value. After more 30 minutes it decays 0.45 points of it's value. Finally, after another 30 minutes it decays 0.30 of its value returning to 0. But how can a trend be detected? Imagine that thousands of people hits the same hashtag at the same time, this hashtag will have thousands of energy points and if you have an ordered list of hashtags this one will surely be on top, but after a few minutes if this hashtag doesn't receive any more energy points it will start to loose it's energy and decay over time.

Configuration
-------------

[](#configuration)

To configure your decaying time you can set the `energy_decay` parameter in `config/trends.php`. The decaying time is measured in hours.

Preparing your model
--------------------

[](#preparing-your-model)

To allow your model to work with Trends you'll need to implement the HasEnergy trait. And in order to return the current model's energy value, add `energy_amount` to your serialization.

```
use Hacklabs\Trends\Traits\HasEnergy;

class Hashtag extends Model
{
    use HasEnergy;

    protected $appends = ['energy_amount'];
}
```

Usage
-----

[](#usage)

To add energy to your model use the following method:

```
$hashtag->addEnergy(1);
```

To get the current value:

```
$hashtag->energy->amount;
```

Examples
--------

[](#examples)

```
$hashtags = Hashtag::all();

$orderedHashtags = $hashtags->sortByDesc('energy_amount');
```

The above code creates a ordered list of hashtags based on trends.

License
-------

[](#license)

Laravel Trends is open-sourced software licensed under the [MIT license](LICENSE.md).

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 71.4% 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 ~281 days

Total

5

Last Release

1112d ago

Major Versions

v0.1.1 → 1.x-dev2020-03-30

PHP version history (2 changes)v0.1.0PHP ^7.2

v0.1.3PHP ^7.2|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/d0fc2889c47f9b45132fbd2ddded9d07ba13f0d46fc0ac896f8e18ca25d2b25e?d=identicon)[wsenjer](/maintainers/wsenjer)

---

Top Contributors

[![hacklabsdev](https://avatars.githubusercontent.com/u/61810788?v=4)](https://github.com/hacklabsdev "hacklabsdev (5 commits)")[![jbaron-mx](https://avatars.githubusercontent.com/u/11150471?v=4)](https://github.com/jbaron-mx "jbaron-mx (1 commits)")[![wsenjer](https://avatars.githubusercontent.com/u/132250?v=4)](https://github.com/wsenjer "wsenjer (1 commits)")

### Embed Badge

![Health badge](/badges/wsenjer-laravel-trends/health.svg)

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

###  Alternatives

[spatie/laravel-health

Monitor the health of a Laravel application

85810.0M83](/packages/spatie-laravel-health)[watson/validating

Eloquent model validating trait.

9723.3M47](/packages/watson-validating)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)[reedware/laravel-relation-joins

Adds the ability to join on a relationship by name.

2121.2M13](/packages/reedware-laravel-relation-joins)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

44643.1k1](/packages/pressbooks-pressbooks)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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