PHPackages                             eighteen73/laravel-radioactivity - 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. eighteen73/laravel-radioactivity

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

eighteen73/laravel-radioactivity
================================

Laravel Radioactivity provides a lightweight trending system to your application.

v1.1.0(2mo ago)0824MITPHP

Since Dec 13Pushed 2mo agoCompare

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

READMEChangelog (3)Dependencies (8)Versions (4)Used By (0)

Laravel Radioactivity
=====================

[](#laravel-radioactivity)

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

[](#introduction)

Give your eloquent models energy so the most active items are easy to find, with extra energy given to *recently* active items.

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

[](#prerequisites)

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

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

[](#installation)

You may install Laravel Radioactivity via Composer:

```
composer require eighteen73/laravel-radioactivity
```

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

```
php artisan vendor:publish --provider="Eighteen73\Radioactivity\RadioactivityServiceProvider"
```

And finally, you should run your database migrations:

```
php artisan migrate
```

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

[](#how-it-works)

Laravel Radioactivity allows you to create a trending system for any model you want. E.g. assuming a `half_life` set to `24`, and receiving 1000 points of energy initially, after 24 hours this energy would be now 500, and continues to decrement exponentially according to the decay equation.

But how can a trend be detected? Imagine that thousands of people hit the same item at the same time, this item will have thousands of energy points and if you have an ordered list of items this one will surely be on top, but after some time if this item doesn't receive any more energy points it will start to lose its energy and decay over time.

To help avoid the energies table growing too large to sort, this package also prunes models with very low energy (according to your `min_energy` setting).

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

[](#configuration)

To configure your decaying time you can set the `half_life` and `min_energy` parameters in `config/radioactivity.php`. The half life is measured in hours.

If you want to auto-decay the energy on your models then you also need to add your model to the `models` section.

```
'models' => [
    \App\Models\MyModel::class,
],
```

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

[](#preparing-your-model)

To allow your model to work with Laravel Radioactivity 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 Eighteen73\Radioactivity\Traits\HasEnergy;

class MyModel extends Model
{
    use HasEnergy;

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

Usage
-----

[](#usage)

To add energy to your model use the following method. By default, 1000 energy is added each time to avoid lots of floating points, but any desired amount can be added by specifying the `$amount` parameter.

```
$model->addEnergy();    // Adds 1000 energy
$model->addEnergy(100); // Adds 100 energy
```

To get the current value:

```
$model->energy->amount;
```

Schedule
--------

[](#schedule)

This package uses Laravel Schedule to queue decay jobs for each Model type you configure. Make sure you are running [Laravel's Schedule via cron](https://laravel.com/docs/11.x/scheduling#running-the-scheduler) every minute.

```
* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1

```

Examples
--------

[](#examples)

```
# Get Ordered Models by energy (DESC by default)
$orderedModels = MyModel::orderByEnergy('desc')->get();
```

The above code creates a ordered list of items based on radioactivity.

License
-------

[](#license)

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

Credits
-------

[](#credits)

This plugin is forked from the [Laravel Trends](https://github.com/hacklabsdev/laravel-trends) package. All due credit to the authors of that package.

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance84

Actively maintained with recent releases

Popularity15

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 52.2% 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 ~262 days

Total

3

Last Release

82d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/735284?v=4)[Ed Jeavons](/maintainers/edjeavons)[@edjeavons](https://github.com/edjeavons)

---

Top Contributors

[![Muffinman](https://avatars.githubusercontent.com/u/1319568?v=4)](https://github.com/Muffinman "Muffinman (12 commits)")[![edjeavons](https://avatars.githubusercontent.com/u/735284?v=4)](https://github.com/edjeavons "edjeavons (5 commits)")[![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)")

---

Tags

laravellaravel-packageradioactivityvirallaravel

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/eighteen73-laravel-radioactivity/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.4M354](/packages/psalm-plugin-laravel)[laravel/ai

The official AI SDK for Laravel.

1.1k4.6M295](/packages/laravel-ai)[api-platform/laravel

API Platform support for Laravel

58190.1k21](/packages/api-platform-laravel)[illuminate/queue

The Illuminate Queue package.

20433.0M1.8k](/packages/illuminate-queue)[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.

45844.8k1](/packages/pressbooks-pressbooks)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5226.7k](/packages/simplestats-io-laravel-client)

PHPackages © 2026

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