PHPackages                             motomedialab/simple-laravel-audit - 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. motomedialab/simple-laravel-audit

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

motomedialab/simple-laravel-audit
=================================

A simple audit helper that integrates directly with Laravel &amp; FilamentPHP

v2.0.0(1y ago)262.7k↓50%1MITPHPCI passing

Since Aug 16Pushed 1y ago2 watchersCompare

[ Source](https://github.com/motomedialab/simple-laravel-audit)[ Packagist](https://packagist.org/packages/motomedialab/simple-laravel-audit)[ RSS](/packages/motomedialab-simple-laravel-audit/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (5)Versions (14)Used By (0)

Simple Laravel Auditing
=======================

[](#simple-laravel-auditing)

[![GitHub Actions](https://github.com/motomedialab/simple-laravel-audit/actions/workflows/main.yml/badge.svg)](https://github.com/motomedialab/simple-laravel-audit/actions/workflows/main.yml/badge.svg)

A lightweight package to provide the ability and flexibility to quickly and easily audit events and actions that happen within your Laravel application.

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

[](#installation)

You can install the package via composer:

```
composer require motomedialab/simple-laravel-audit
```

Once you've done this, run your migrations. This will create a table called `audit_logs`.

```
php artisan migrate

```

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

[](#configuration)

Out of the box there isn't any requirement to configure the package. It will work with the default settings.

However, if you'd like to customise any options, such as the table name or classes that are utilised, you can publish the config file and change any of the options. It's designed to be flexible allowing you to change IP address resolution, user ID resolution, table name and more.

```
php artisan vendor:publish --tag=simple-auditor

```

### Obfuscating the IP address for compliance

[](#obfuscating-the-ip-address-for-compliance)

You can easily obfuscate IP addresses that are submitted to the database by setting the `SIMPLE_AUDITOR_OBFUSCATE_IP`variable in your `.env` file to true. This will strip the first two octets of an IP address, ensuring it meets various compliance laws, such as GDPR. Behind the scenes this switches the default IP address fetcher with an Obfuscated IP fetcher.

### Setting the retention duration

[](#setting-the-retention-duration)

You can define how many days your logs should be kept for by setting the `SIMPLE_AUDITOR_RETENTION` in your `.env` file. If you want to keep all logs indefinitely, set this to `0`.

```
SIMPLE_AUDITOR_RETENTION=30 # retain for 30 days
SIMPLE_AUDITOR_RETENTION=0 # retain indefinitely
```

Every time the audit logs are pruned, this will be recorded as an audit log itself.

Usage
-----

[](#usage)

There are multiple ways you can use this package. The most common way is to use the `audit` helper function.

### Using the global audit helper

[](#using-the-global-audit-helper)

The `audit` helper function is an easy way to quickly log to the audits table. This function takes a string as the first argument, and an optional array (context) as the second argument. This will only work if you don't already have a global function called `audit`.

```
audit('Action performed', ['more_data' => 'Goes here']);
```

### Using the facade

[](#using-the-facade)

Some people love using Laravel's Facades due to their ease of use and static nature.

```
// import the facade
use Motomedialab\SimpleLaravelAudit\Facades\AuditFacade;

// create our audit log
AuditFacade::audit('Action performed', ['more_data' => 'Goes here']);
```

### Binding to events

[](#binding-to-events)

If you want to audit an event that happens within your application, you can do so by using the `IsAuditableEvent`interface. Coupled with `AuditableEvent`, this will automatically log the event to the audit log.

Here's an example of an event that utilises the `IsAuditableEvent` interface:

```
// import our contract & trait
use Motomedialab\SimpleLaravelAudit\Contracts\IsAuditableEvent;
use Motomedialab\SimpleLaravelAudit\Traits\AuditableEvent;

class MyCustomEvent implements IsAuditableEvent
{
    use AuditableEvent;

    public function handle()
    {
        // ToDo: your event logic.
    }

    // optional - by default will be handled by the AuditableEvent trait
    public function getAuditMessage(): string
    {
        return 'Action performed';
    }

    // optional - by default will be handled by the AuditableEvent trait
    public function getAuditContext(): array
    {
        return ['more_data' => 'Goes here'];
    }
}
```

### Using the `AuditableModel` trait on Models

[](#using-the-auditablemodel-trait-on-models)

If you have a model that you'd like to be audited on change, you can use the `AuditableModel` trait. By default, this will record all creations, updates and deletions for this model to the audit log. This uses Laravel model observers to listen for changes. By default, the `created_at` and `updated_at` columns are excluded from auditing.

```
use Illuminate\Database\Eloquent\Model;
use Motomedialab\SimpleLaravelAudit\Traits\AuditableModel;

class YourModel extends Model
{
    use AuditableModel;

    /**
    * An array of columns that shouldn't be audited.
    * @var array|string[]
    */
    protected array $excludedFromAuditing = [
        'created_at',
        'updated_at',
    ];
}
```

#### Customising the `AuditableModel` functionality

[](#customising-the-auditablemodel-functionality)

If you'd like to expand the functionality of the `AuditableModel` trait, you can override its observer by configuring the `observer` key in the config file. This will allow you to create your own model observer.

```
use Motomedialab\SimpleLaravelAudit\Observers\AuditableModelObserver as BaseObserver;

class AuditableObserver extends BaseObserver
{
    // your custom classes here
    // see https://laravel.com/docs/11.x/eloquent#observers for more information
}
```

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.

License
-------

[](#license)

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

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance47

Moderate activity, may be stable

Popularity30

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90.5% 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 ~22 days

Recently: every ~60 days

Total

12

Last Release

391d ago

Major Versions

v1.4.0 → v2.0.02025-04-16

### Community

Maintainers

![](https://www.gravatar.com/avatar/805ae1048fb81d8f02871f57cc0a34699089da17f7021210e554ffdba4df918a?d=identicon)[chrispage1](/maintainers/chrispage1)

---

Top Contributors

[![chrispage1](https://avatars.githubusercontent.com/u/2487374?v=4)](https://github.com/chrispage1 "chrispage1 (19 commits)")[![lewislarsen](https://avatars.githubusercontent.com/u/2665668?v=4)](https://github.com/lewislarsen "lewislarsen (1 commits)")[![timmydhooghe](https://avatars.githubusercontent.com/u/63366355?v=4)](https://github.com/timmydhooghe "timmydhooghe (1 commits)")

---

Tags

laravelAuditfilamentmotomedialabchrispage1

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/motomedialab-simple-laravel-audit/health.svg)

```
[![Health](https://phpackages.com/badges/motomedialab-simple-laravel-audit/health.svg)](https://phpackages.com/packages/motomedialab-simple-laravel-audit)
```

###  Alternatives

[tapp/filament-auditing

Filament Laravel Auditing plugin.

113379.4k2](/packages/tapp-filament-auditing)[marcogermani87/filament-cookie-consent

Easy cookie consent integrations for Filament

1917.0k](/packages/marcogermani87-filament-cookie-consent)[afs19/filament-vertical-tabs

A Filament v3 package that adds vertical tabs functionality

142.2k](/packages/afs19-filament-vertical-tabs)

PHPackages © 2026

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