PHPackages                             ttpn18121996/historical-records - 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. ttpn18121996/historical-records

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

ttpn18121996/historical-records
===============================

Record the history of activities affecting the database in a simple way.

v2.2.3(1mo ago)093[1 PRs](https://github.com/ttpn18121996/historical-records/pulls)MITPHPPHP ^8.2CI passing

Since May 23Pushed 1mo ago1 watchersCompare

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

READMEChangelog (10)Dependencies (10)Versions (20)Used By (0)

Historical records
==================

[](#historical-records)

General
-------

[](#general)

Record the history of activities affecting the database in a simple way.

[`PHP v8.2`](https://php.net)

[`Laravel v11.x`](https://github.com/laravel/laravel)

Content
-------

[](#content)

- [Installation](#installation)
- [Basic usage](#basic-usage)
- [Save history](#save-history)
- [The model configuration used for the HistoryManager](#the-model-configuration-used-for-the-historymanager)
- [History cleanup](#history-cleanup)
- [Show user actions and locale](#show-user-actions-and-locale)
- [Configurations](#configurations)
    - [History retention period](#history-retention-period)
    - [Names of devices that will save history](#names-of-devices-that-will-save-history)

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

[](#installation)

Install using composer:

```
composer require ttpn18121996/historical-records
```

Next, publish HistoricalRecords's resources using the `historical-records:install` command:

```
php artisan historical-records:install
```

Basic usage
-----------

[](#basic-usage)

First, add the HistoricalRecords\\Concerns\\HasHistory trait to your User model(s):

```
use Illuminate\Foundation\Auth\User as Authenticatable;
use HistoricalRecords\Concerns\HasHistory;
use HistoricalRecords\Contracts\Historyable;

class User extends Authenticatable implements Historyable
{
    use HasHistory;

    //...
}
```

Save history
------------

[](#save-history)

```
use HistoricalRecords\HistoryManager;

/*
id: 1
name: Trinh Tran Phuong Nam
email: ttpn18121996@example.com
*/
$user = auth()->user();

$history = HistoryManager::save(
    historyable: $user,
    feature: 'users',
    keyword: 'create',
    payload: ['id' => 2, 'name' => 'Minh Nguyet', 'email' => 'minhnguyet@example.com'],
);

echo sprintf(__('history.'.$history->feature.'.'.$history->keyword.'.action'), $user->name);
// Trinh Tran Phuong Nam has created a user.
```

The model configuration used for the HistoryManager
---------------------------------------------------

[](#the-model-configuration-used-for-the-historymanager)

```
use App\Models\History;
use HistoricalRecords\HistoryManager;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    public function register()
    {
        HistoryManager::useModel(History::class);
    }
}
```

History cleanup
---------------

[](#history-cleanup)

---

Run the command to delete history more than 30 days

```
php artisan historical-records:cleanup
```

If you want to specify the number of days to exceed to clear the history, pass the option `--time=`. Valid values:

```

#Ex:
7d|7days => 7 days
1m|1months => 1 month
1y|1years => 1 year

```

```
php artisan historical-records:cleanup --time=14days
#OR
php artisan historical-records:cleanup -t 14d
```

Show user actions and locale
----------------------------

[](#show-user-actions-and-locale)

We support 1 set of languages ​​to display user actions in the file `lang/en/historical.php`.

```
return [
    'users' => [
        'create' => [
            'title' => 'Create',
            'action' => '%s has created a user.',
        ],
        'update' => [
            'title' => 'Update',
            'action' => '%s has updated a user.',
        ],
        'delete' => [
            'title' => 'Delete',
            'action' => '%s has deleted a user.',
        ],
        'destroy' => [
            'title' => 'Force delete',
            'action' => '%s has hard deleted a user.',
        ],
        'restore' => [
            'title' => 'Restore',
            'action' => '%s has restored a user.',
        ],
        'login' => [
            'title' => 'Login',
            'action' => '%s has logged in.',
        ],
        'change_password' => [
            'title' => 'Change password',
            'action' => '%s has changed the login account password.',
        ],
        'update_profile' => [
            'title' => 'Update profile',
            'action' => '%s has updated the profile.',
        ],
        'email_verification' => [
            'title' => 'Email verification',
            'action' => '%s has verified the email.',
        ],
    ],
];
```

The model supports user action methods. We can rely on the language file to display user actions.

Suppose we have historical information

```
/*
User [
    'id' => 1
    'name' => 'John Doe'
]
History [
    'feature' => 'users',
    'ketword' => 'create'
    'historyable_id' => 1,
    'historyable_type' => App\Models\User,
]
*/
$history = History::first();

echo $history->action_for_trans;

// historical.users.create.action
// :name has created a user.

__($history->action_for_trans, ['name' => $history->user->name]);

// John Doe has created a user
```

Configurations
--------------

[](#configurations)

Configuration parameters will be stored in the file `config/historical-records.php`.

### History retention period

[](#history-retention-period)

You can configure the history period for cleaning. By default, history will be stored within 90 days.

```
return [
    'history_expires' => 90, // days
    ...
];
```

### Names of devices that will save history

[](#names-of-devices-that-will-save-history)

You can configure device names to save history.

```
return [
    ...
    'device_name' => [ // device name that will be saved
        'phone' => 'phone',
        'tablet' => 'tablet',
        'desktop' => 'desktop',
        'default' => 'unknown',
    ],
];
```

###  Health Score

45

—

FairBetter than 92% of packages

Maintenance90

Actively maintained with recent releases

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity62

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 ~39 days

Recently: every ~98 days

Total

18

Last Release

45d ago

Major Versions

v1.1.6 → v2.0.12024-10-12

v1.x-dev → v2.1.02024-11-07

v2.x-dev → v3.x-dev2026-03-28

### Community

Maintainers

![](https://www.gravatar.com/avatar/7e29c5467ccb05064bc324441f54910b45af2d6cb6ec198e47914dd560e9f5fe?d=identicon)[ttpn18121996](/maintainers/ttpn18121996)

---

Top Contributors

[![ttpn18121996](https://avatars.githubusercontent.com/u/24547728?v=4)](https://github.com/ttpn18121996 "ttpn18121996 (63 commits)")

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/ttpn18121996-historical-records/health.svg)

```
[![Health](https://phpackages.com/badges/ttpn18121996-historical-records/health.svg)](https://phpackages.com/packages/ttpn18121996-historical-records)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[aedart/athenaeum

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

255.2k](/packages/aedart-athenaeum)[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M158](/packages/orchestra-canvas)[yajra/laravel-datatables-editor

Laravel DataTables Editor plugin for Laravel 5.5+.

1186.1M2](/packages/yajra-laravel-datatables-editor)[recca0120/laravel-erd

Laravel ERD automatically generates Entity-Relationship Diagrams from your Laravel models and displays them using Vuerd.

36072.0k](/packages/recca0120-laravel-erd)[spatie/laravel-morph-map-generator

Automatically generate morph maps in your Laravel application

73464.9k1](/packages/spatie-laravel-morph-map-generator)

PHPackages © 2026

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