PHPackages                             nh/trackable - 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. nh/trackable

ActiveLibrary

nh/trackable
============

Make a Laravel model trackable

1.7.1(3y ago)02771MITPHP

Since Apr 30Pushed 3y ago1 watchersCompare

[ Source](https://github.com/NatachaH/laravel-trackable)[ Packagist](https://packagist.org/packages/nh/trackable)[ RSS](/packages/nh-trackable/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (10)DependenciesVersions (24)Used By (1)

Installation
============

[](#installation)

Install the package via composer:

```
composer require nh/trackable

```

Publish the translation and the model for the trackable:

```
php artisan vendor:publish --tag=trackable

```

To make a model trackable, add the **Trackable** trait to your model: *To retrieve the tracks of your model =&gt; $post-&gt;tracks**To check if of your model has any tracks =&gt; $post-&gt;hasTracks()*

```
use Nh\Trackable\Traits\Trackable;

use Trackable;

```

The events available for the model are:

- created
- updated
- deleted
- soft-deleted
- restored
- force-deleted
- saved
- changed

You can retrieve the tracks (order by date and id) of a model:

```
$model->tracks;

```

Or you can retrieve the most recent track

```
$model->latestTrack;

```

Model
-----

[](#model)

You can retrieve multiple information per track: *You can customize the translations, colors and icons via the trackable config file*

```
$track->event_name;       // The translated name of the event
$track->event_color;      // The color of the event
$track->event_icon;       // The icon of the event
$track->model;            // The clean model name
$track->model_name;       // The translated model name
$track->relation_model;   // The clean relation model name
$track->relation_name;    // The translated relation model name
$track->relation_icon;    // The icon of the relation model
$track->username;         // The username
$track->time;             // The formated time
$track->formated // Return 'Updated 3m ago by Natacha'

```

Add a track
-----------

[](#add-a-track)

You can add a custom track for a model:

```
$model->addTrack('my-event', $relationModel, $numberRelationModelAffected, 'My comment')

```

Event listener
--------------

[](#event-listener)

You can track some event by using the listener **AddTrack**.

Add this lines to your property **$listen** in your **App\\Providers\\EventServiceProvider.php** :

Your event should return:

- $event-&gt;name as the name of the event (exemple: created)
- $event-&gt;model as the model who is tracked)
- $event-&gt;relation as the model relation (exemple: App\\Models\\Role)
- $event-&gt;number as the number of items affected (model or relation) by the event

```
MyCustomEvent::class => [
    \Nh\Trackable\Listeners\AddTrack::class
]

```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~45 days

Recently: every ~126 days

Total

23

Last Release

1215d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/47361520c40f781d7d5b39e26b3194800a35e89c4819c220ea3eaaaa907c34ec?d=identicon)[NatachaH](/maintainers/NatachaH)

---

Top Contributors

[![NatachaH](https://avatars.githubusercontent.com/u/24412486?v=4)](https://github.com/NatachaH "NatachaH (55 commits)")

### Embed Badge

![Health badge](/badges/nh-trackable/health.svg)

```
[![Health](https://phpackages.com/badges/nh-trackable/health.svg)](https://phpackages.com/packages/nh-trackable)
```

PHPackages © 2026

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