PHPackages                             kuncen/audittrails - 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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. kuncen/audittrails

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

kuncen/audittrails
==================

Log jejak audit transaksional data pada aplikasi laravel

v2.0.9(2mo ago)0388MITPHPPHP ^8.0CI passing

Since Sep 7Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/MFadlulHafiizh/Audit-Trails)[ Packagist](https://packagist.org/packages/kuncen/audittrails)[ RSS](/packages/kuncen-audittrails/feed)WikiDiscussions main Synced yesterday

READMEChangelogDependencies (14)Versions (24)Used By (0)

Laravel Audit Trail Package
===========================

[](#laravel-audit-trail-package)

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

[](#installation)

Laravel activity log requires `laravel 8` or higher and `php 8.0+`

```
composer require kuncen/audittrails

```

Then add `Kuncen\Audittrails\AudittrailsServiceProvider::class` to config/app.php or bootstrap/providers.php on laravel 11

```
 'providers' => ServiceProvider::defaultProviders()->merge([
        /*
         * Package Service Providers...
         */

        /*
         * Application Service Providers...
         */
         ...
         ...
         Kuncen\Audittrails\AudittrailsServiceProvider::class,
 ])->toArray(),
```

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

[](#configuration)

After installing the activity log you must publish its config using command:

```
php artisan vendor:publish --provider="Kuncen\Audittrails\AudittrailsServiceProvider"

```

After that activity log will create the table on your application to store transactional data. that's why you need to `migrate` your database

```
php artisan migrate

```

New V2 Features
---------------

[](#new-v2-features)

### Set transaction identitiy

[](#set-transaction-identitiy)

if your table has `created_by`, `updated_by` and `deleted_by` columns, these options will be filled automatically. Add the following variable to your model to enable this feature:

```
class Car extends Models
{
    use LogTransaction;

    protected $table = 'car';
    ...
    ...

    protected $useUserIdentityForTransaction = true where('id', $this->getOriginal('car_id'))->first();
        $data['new_values']['car_detail'] = Car::find($this->getOriginal('car_id'));
    }
    return $data;
}
```

### Grouping multiple logs using batch

[](#grouping-multiple-logs-using-batch)

You can now group multiple logs, whether related to the same model or not when an action is performed simultaneously within a function.

```
$uniqId = uniqid();
$user = User::setBatchAudit($uniqId)->find(2);
$user->name = "Example User";
$user->email = "dummy@gmail.com";
$user->password = "test";
$user->role_id = 1;
$user->save();

for ($i=0; $i < 3; $i++) {
    $car = new Car;
    $car->setBatchAudit($uniqId);
    $car->user_id = $user->id;
    $car->car_name = "Example Car " . $i;
    $car->save();
}
```

### Add description log

[](#add-description-log)

Adding some description using setDescAudit()

```
$uniqId = uniqid();
$data = User::setBatchAudit($uniqId)->setDescAudit('Some description')->find(2);
$data->name = "Example User";
$data->email = "dummy@gmail.com";
$data->password = bcrypt("123");
$data->role_id = 1;
$data->save();
```

Usage
-----

[](#usage)

This package automatically save all transactional activity like save, update, delete, login and logout. But before use, you must add `LogTransaction` trait on your Models like this

```
use Laravel\Sanctum\HasApiTokens;
use Kuncen\Audittrails\LogTransaction;
use Illuminate\Notifications\Notifiable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use HasApiTokens, HasFactory, Notifiable, LogTransaction;
}
```

Set foreign key values, If you want to add reference value of your foreign key, add this to your models

```
    protected $setForeignValues = [
        [
            "foreign"         => "role_id", //foreign key in your models
            "reference_table" => "role", //reference table of your foreign key
            "reference_table_primary" => "role_id", //primary key of your reference table (not required default value is 'id')
            "target_value"    => "nama_role" //this is the name of a column that you want to put on log
        ],

        //repeat add the array if foreign key more than 1
        [
            "foreign"         => "other_foreign",
            "reference_table" => "some_table",
            "target_value"    => "some_target_column"
        ]
    ];
```

By default if you write this on your models it will replace foreign key id to foreign key value you set in this array. But if you still want to keep foreign key id and add foreign key value without replace it, you can add `hideForeignId(false)`

```
    $data = User::hideForeignId(false)->find(1);
    $data->name = "Dummy Example";
    $data->email = "dummy@gmail.com";
    $data->password = bcrypt("examplepassword");
    $data->update();
```

All transactions data carried out before login like forgot password and register will probably store the null value in user\_id column in the table activity\_log. If you still need the user identity in the transaction you can cast user id using `withAuth()`, like this:

```
$data = User::withAuth(17)->find(1);
$data->name = "Dummy Example";
$data->email = "dummy@gmail.com";
$data->password = bcrypt("examplepassword");
$data->update();
```

Disable logging for some function

```
$data = User::disableAudit(true)->find(1);
$data->name = "Dummy Example";
$data->email = "dummy@gmail.com";
$data->password = bcrypt("examplepassword");
$data->update();
```

If you want all transactional in your application to be recorded as entering a menu or page that another than action to save(), update(), delete() login and logout. You can add `setActivityLog()` helper to the function you made

```
setActivityLog(
    "description about this function/page/menu (opsional default is null)",
    user id (opsional if you need user identity for your function default is null),
    http method or action (opsional by default value is "READ"),
    "New values what you need to store it (opsional)",
    "Old values what you need to store it (opsional)"
);
```

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance88

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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

Every ~44 days

Recently: every ~64 days

Total

23

Last Release

60d ago

Major Versions

v1.1.1 → v2.x-dev2025-04-16

PHP version history (3 changes)v1.0PHP ^8.0

v1.0.1PHP ^7.4|^8.0

v1.x-devPHP ^7.3|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/2b99f20e76c246f5275587a52bfd5775ac4a9ded3fb4efe7c0e4ffc9c390a4ee?d=identicon)[rrkuncen](/maintainers/rrkuncen)

---

Top Contributors

[![MFadlulHafiizh](https://avatars.githubusercontent.com/u/61264072?v=4)](https://github.com/MFadlulHafiizh "MFadlulHafiizh (2 commits)")

---

Tags

activity-logauditaudit-trailslaravelloggingpackageloglaravelAuthenticationaudit-trailtransaction Log

### Embed Badge

![Health badge](/badges/kuncen-audittrails/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k15.1M132](/packages/laravel-pulse)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M131](/packages/roots-acorn)[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M194](/packages/laravel-ai)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

77022.3M151](/packages/laravel-mcp)[api-platform/laravel

API Platform support for Laravel

58171.5k14](/packages/api-platform-laravel)

PHPackages © 2026

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