PHPackages                             jonasschen/laravel-easy-audits - 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. [Database &amp; ORM](/categories/database)
4. /
5. jonasschen/laravel-easy-audits

ActiveLibrary[Database &amp; ORM](/categories/database)

jonasschen/laravel-easy-audits
==============================

A quick and easy way to audit changes to your Laravel project's database

v1.0.0(7mo ago)016↓100%MITPHPPHP ^8.3

Since Oct 3Pushed 2mo agoCompare

[ Source](https://github.com/jonasschen/laravel-easy-audits)[ Packagist](https://packagist.org/packages/jonasschen/laravel-easy-audits)[ Docs](https://github.com/jonasschen/laravel-easy-audits)[ Fund](https://bmc.link/jonasschen)[ GitHub Sponsors](https://github.com/jonasschen)[ RSS](/packages/jonasschen-laravel-easy-audits/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

 [![Logo](assets/logo_easy_audits.jpg)](assets/logo_easy_audits.jpg)

Laravel Easy Audits
===================

[](#laravel-easy-audits)

[![Latest Version on Packagist](https://camo.githubusercontent.com/7ff595907dce7c4b906e8319a298888c22dde312a642ed81f6ed4452e44365c3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a6f6e6173736368656e2f6c61726176656c2d656173792d6175646974732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jonasschen/laravel-easy-audits)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/89d17a9d26999f69d804b219e4ded6a3f2c539f1d9e32693a15300b054292404/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a6f6e6173736368656e2f6c61726176656c2d656173792d6175646974732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jonasschen/laravel-easy-audits)

A quick and easy way to audit changes to your Laravel project's database.

Using Laravel Easy Audits, you can easily audit all database changes.

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

[](#installation)

### You can install the package via composer:

[](#you-can-install-the-package-via-composer)

```
composer require jonasschen/laravel-easy-audits
```

### Publish the config files using the artisan CLI tool:

[](#publish-the-config-files-using-the-artisan-cli-tool)

```
php artisan vendor:publish --tag=easy-audits-config
```

This command will publish the config file: `config/easy-audits.php`

**Available configurations:**

- audit\_table\_name \[Audit table name\]: Table name where audit logs will be stored. NOTE: After the migrate process has been executed, changing this configuration will break the package.
    - Default Value:

    ```
    'audit_table_name' => 'audits',
    ```
- enabled\_triggers \[Enabled Triggers\]: You can customize which types of changes you want to audit. This setting is global and affects all enabled models/entities in the project, unless this setting is overridden via the model/entity's $enabledTriggers property.
    - Default Value:

    ```
    'enabled_triggers' => [
        'insert',
        'update',
        'delete',
        'soft_delete',
        'force_delete',
        'restore',
    ],
    ```
- model\_class \[Model class\]: Model class to be used to persist in the database. You can change this configuration if you want to override the model class.
    - Default Value:

    ```
    'model_class' => EasyAudit::class,
    ```
- observer\_class \[Observer class\]: Observer class to be used to persist in the database. You can change this configuration if you want to override the observer class.
    - Default Value:

    ```
    'observer_class' => EasyAuditsObserver::class,
    ```
- audits\_ttl \[Audits time-to-life (in days)\]: Quantity of **days** audit logs should remain in the database before being pruned. Zero means no pruning.
    - Default Value:

    ```
    'audits_ttl' => 0,
    ```

### Publish the migration files using the artisan CLI tool ( (OPTIONAL):

[](#publish-the-migration-files-using-the-artisan-cli-tool--optional)

If you want to customize the migration file, you can publish it within your project.

BUT BE CAREFUL, it is at your own risk; changes to the table structure may cause this package break.

```
php artisan vendor:publish --tag=easy-audits-migrations
```

This command will publish the migration file: `database/migrations/2025_10_01_000000_create_audits_table.php`

Usage
-----

[](#usage)

To enable auditing for a table, you only need to declare the `EasyAuditsTrait` trait in your model/entity.

```
use Jonasschen\LaravelEasyAudits\Traits\EasyAuditsTrait;

class User extends Model
{
    use EasyAuditsTrait;
}
```

Ready! Now, every time you make a change to your model/entity, a new record will be created in the audit table.

This package is compatible with SoftDeletes and is able to audit the following types of changes: `insert`, `update`, `delete`, `soft_delete`, `force_delete` and `restore`.

### Available properties

[](#available-properties)

The following properties are available to customize how auditing is performed on each model/entity:

- `$auditableAttributes`: Use this property when you want to audit only changes to specific fields. By default, all fields will always be audited.

```
protected array $auditableAttributes = [
    'name',
    'email',
];
```

- `$nonAuditableAttributes`: Use this property when you want to remove specific fields from the audit. By default, all fields will always be audited.

```
protected array $nonAuditableAttributes = [
    'password',
    'remember_token',
    'updated_at',
];
```

- `$disableTriggers`: Use this property when you want to disable auditing for a specific change type. Accepted values are: `insert`, `update`, `delete`, `soft_delete`, `force_delete` and `restore`. By default, all change types are audited.

```
protected array $disableTriggers = [
    'restore',
    'soft_delete',
];
```

Pruning logs
------------

[](#pruning-logs)

It is possible to prune audited logs. However, before doing so, it is important to review the `audits_ttl` setting in your `config/easy-audits.php` file.

This setting set the package how many days logs should remain in the database before being deleted.

If you want to keep the data indefinitely, you must enter a value of 0 (zero) in the configuration.

### There are two ways to perform log pruning:

[](#there-are-two-ways-to-perform-log-pruning)

1. **FIRST WAY TO PRUNE LOGS**: Using the artisan command

Use the command below.

```
php artisan easy_audits:prune
```

#### Output example

[](#output-example)

```
****************************************
*  LARAVEL EASY AUDITS PRUNING REPORT  *
****************************************
TTL loaded from config file: 14 days
Pruned [800] records in [0.22] seconds.

```

You can also use the `--audits_ttl` parameter to specify a custom TTL and ignore the configuration file:

Use the command below.

```
php artisan easy_audits:prune --audits_ttl=30
```

#### Output example

[](#output-example-1)

```
****************************************
*  LARAVEL EASY AUDITS PRUNING REPORT  *
****************************************
TTL loaded from option parameter: 30 days
Pruned [1400] records in [0.28] seconds.

```

2. **SECOND WAY TO PRUNE LOGS**: Using Schedule

If you find it useful, you can also set up a schedule to automatically run the pruning at your preferred time.

To do this, simply add the following code to your project's `AppServiceProvider` class, which is usually located at `app/Providers/AppServiceProvider.php`

```
use Jonasschen\LaravelEasyAudits\Jobs\EasyAuditsPruneJob;
use Illuminate\Console\Scheduling\Schedule;

public function boot(): void
{
    /*** Other implementations here ***/

    $this->callAfterResolving(Schedule::class, fn (Schedule $schedule) =>
        $schedule->job(new EasyAuditsPruneJob())->dailyAt('01:00')
    );
}
```

NOTE: In the schedule settings, you are free to use any scheduling frequency supported by your Laravel version. E.g. `->everyThirtyMinutes()`, `->hourly()`, `->daily()`, `->weekly()`, `->monthly()`, `->quarterly()`, `->yearly()`, etc.

Troubleshooting
---------------

[](#troubleshooting)

- If you get an error when running the migration or prune commands, please check if the all configurations are set to the correct value.
- If you get an error when running the migration, please check if the audit table already exists.
- If you get an error when running any command, please make sure you have the required Laravel PHP extensions installed in your PHP CLI.

Consider Sponsoring
-------------------

[](#consider-sponsoring)

Help me maintain this project, please consider looking at the [FUNDING](./.github/FUNDING.yml) file for more info.

[![Buy Me A Coffee](https://camo.githubusercontent.com/9f44ce2dc3b3eecdd02598900866ffc518801df1932849703dae1e5ce5031070/68747470733a2f2f7777772e6275796d6561636f666665652e636f6d2f6173736574732f696d672f637573746f6d5f696d616765732f6f72616e67655f696d672e706e67)](https://bmc.link/jonasschen)

#### BTC

[](#btc)

[![btc](https://private-user-images.githubusercontent.com/31046817/243049755-2f69a4aa-4ee2-442e-aa1f-4a1c0cde217c.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzUzMjk5MDQsIm5iZiI6MTc3NTMyOTYwNCwicGF0aCI6Ii8zMTA0NjgxNy8yNDMwNDk3NTUtMmY2OWE0YWEtNGVlMi00NDJlLWFhMWYtNGExYzBjZGUyMTdjLnBuZz9YLUFtei1BbG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z1ob3N0In0.nhM5946tAVoCAHttdjEHvo0mWI7Z-kCMwjvoChKXFRg)

#### ETH

[](#eth)

[![eth](https://private-user-images.githubusercontent.com/31046817/243049936-41ca0d2f-e120-4733-a96b-ff7a34e1e4de.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzUzMjk5MDQsIm5iZiI6MTc3NTMyOTYwNCwicGF0aCI6Ii8zMTA0NjgxNy8yNDMwNDk5MzYtNDFjYTBkMmYtZTEyMC00NzMzLWE5NmItZmY3YTM0ZTFlNGRlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjA0MDQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwNDA0VDE5MDY0NFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWVhZGYwOWI1MThmZTdiMzEzMzE0NTBlMGU2Zjk3ZWY3ZmEyNDViOGFjNThhYWI2MDg3ZmU0MjQ1MTRlNDI4OTgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.a8xfsB-leYaxwaNRIuPqPj5WgSZ3B8FkeDE_zr95l8g)](https://private-user-images.githubusercontent.com/31046817/243049936-41ca0d2f-e120-4733-a96b-ff7a34e1e4de.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzUzMjk5MDQsIm5iZiI6MTc3NTMyOTYwNCwicGF0aCI6Ii8zMTA0NjgxNy8yNDMwNDk5MzYtNDFjYTBkMmYtZTEyMC00NzMzLWE5NmItZmY3YTM0ZTFlNGRlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjA0MDQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwNDA0VDE5MDY0NFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWVhZGYwOWI1MThmZTdiMzEzMzE0NTBlMGU2Zjk3ZWY3ZmEyNDViOGFjNThhYWI2MDg3ZmU0MjQ1MTRlNDI4OTgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.a8xfsB-leYaxwaNRIuPqPj5WgSZ3B8FkeDE_zr95l8g)

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information about recent changes.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security-related issues, please email  instead of using the issue tracker. Please do not email any questions, open an issue if you have a question.

Credits
-------

[](#credits)

- [Jonas Schen](https://github.com/jonasschen)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance77

Regular maintenance activity

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

221d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/726e9421b6682d1730e00fb93929d3b2158a3e025d871a92fcb8641e2ffa8d02?d=identicon)[jonasschen](/maintainers/jonasschen)

---

Top Contributors

[![jonasschen](https://avatars.githubusercontent.com/u/31046817?v=4)](https://github.com/jonasschen "jonasschen (3 commits)")

---

Tags

auditsdatabaselaravellogphploglaravellogsAuditauditingauditsjonasschenlaravel-easy-auditslaravel-auditsjonas schenschen

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jonasschen-laravel-easy-audits/health.svg)

```
[![Health](https://phpackages.com/badges/jonasschen-laravel-easy-audits/health.svg)](https://phpackages.com/packages/jonasschen-laravel-easy-audits)
```

###  Alternatives

[owen-it/laravel-auditing

Audit changes of your Eloquent models in Laravel

3.4k33.0M95](/packages/owen-it-laravel-auditing)[altek/accountant

The auditing &amp; accountability package for Laravel's Eloquent ORM.

92954.3k4](/packages/altek-accountant)[betapeak/laravel-auditing-filesystem

A filesystem driver for the owen-it/laravel-auditing package. Allows storage of the audits in CSV files, across all registered Laravel disks.

166.5k](/packages/betapeak-laravel-auditing-filesystem)

PHPackages © 2026

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