PHPackages                             roketin/laravel-auditing - 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. roketin/laravel-auditing

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

roketin/laravel-auditing
========================

personal used for Roketin Engine. Keep a change history for your models using laravel version 5.\*

2.0(10y ago)15.3kMITPHPPHP &gt;=5.5.9

Since Aug 28Pushed 10y ago1 watchersCompare

[ Source](https://github.com/roketin/laravel-auditing)[ Packagist](https://packagist.org/packages/roketin/laravel-auditing)[ Docs](https://github.com/roketin/laravel-auditing)[ RSS](/packages/roketin-laravel-auditing/feed)WikiDiscussions master Synced today

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

[![Latest Stable Version](https://camo.githubusercontent.com/fb13010f35f54f5529d32324182d56a063bbd881e2da74bd67e89071a24c51ca/68747470733a2f2f706f7365722e707567782e6f72672f726f6b6574696e2f6c61726176656c2d6175646974696e672f76657273696f6e)](https://packagist.org/packages/roketin/laravel-auditing)[![Total Downloads](https://camo.githubusercontent.com/dcd30f4a699f7b451f1e2542611752a3718efc9b5dd71c40e62af073bc70311f/68747470733a2f2f706f7365722e707567782e6f72672f726f6b6574696e2f6c61726176656c2d6175646974696e672f646f776e6c6f616473)](https://packagist.org/packages/roketin/laravel-auditing)[![Latest Unstable Version](https://camo.githubusercontent.com/e7a881a43419e68d854e882980be02c219e854b13309ff5f779cc27279a9843f/68747470733a2f2f706f7365722e707567782e6f72672f726f6b6574696e2f6c61726176656c2d6175646974696e672f762f756e737461626c65)](//packagist.org/packages/roketin/laravel-auditing)[![License](https://camo.githubusercontent.com/3b158a382fa65e136e96094bf62c04e0c53f06830ee07db1ef948eb4d19a1098/68747470733a2f2f706f7365722e707567782e6f72672f726f6b6574696e2f6c61726176656c2d6175646974696e672f6c6963656e73652e737667)](https://packagist.org/packages/roketin/laravel-auditing)

Laravel Auditing allows you to record changes to an Eloquent model's set of data by simply adding its trait to your model. Laravel Auditing also provides a simple interface for retreiving an audit trail for a piece of data and allows for a great deal of customization in how that data is provided.

> Auditing is based on the package [auditing](https://packagist.org/packages/owen-it/laravel-auditing)

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

[](#installation)

Laravel Auditing can be installed with [Composer](http://getcomposer.org/doc/00-intro.md), more details about this package in Composer can be found [here](https://packagist.org/packages/roketin/laravel-auditing).

Run the following command to get the latest version package:

```
composer require roketin/laravel-auditing

```

Open the file `config/app.php` and then add the service provider, this step is required.

```
'providers' => [
    // ...
    Roketin\Auditing\AuditingServiceProvider::class,
],
```

> Note: This provider is important for the publication of configuration files.

Only after complete the step before, use the following command to publish configuration settings:

```
php artisan vendor:publish --provider="Roketin\Auditing\AuditingServiceProvider"

```

Finally, execute the migration to create the `logs` table in your database. This table is used to save audit the logs.

```
php artisan migrate

```

Docs
----

[](#docs)

- [Implementation](#implementation)
- [Configuration](#configuration)
- [Getting the Logs](#getting)
- [Customizing log message](#customizing)
- [Examples](#examples)
- [Contributing](#contributing)
- [Having problems?](#faq)
- [license](#license)

Implementation
--------------

[](#implementation)

### Implementation using `Trait`

[](#implementation-using-trait)

To register the change log, use the trait `OwnerIt\Auditing\AuditingTrait` in the model you want to audit

```
// app/Team.php
namespace App;

use Illuminate\Database\Eloquent\Model;
use Roketin\Auditing\AuditingTrait;

class Team extends Model
{
    use AuditingTrait;
    //...
}
```

### Base implementation Legacy Class

[](#base-implementation-legacy-class)

It is also possible to have your model extend the `OwnerIt\Auditing\Auditing` class to enable auditing. Example:

```
// app/Team.php
namespace App;

use Roketin\Auditing\Auditing;

class Team extends Auditing
{
    //...
}
```

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

[](#configuration)

### Auditing behavior settings

[](#auditing-behavior-settings)

The Auditing behavior settings are carried out with the declaration of attributes in the model. See the examples below:

- Turn off logging after a number of logs: `$historyLimit = 500`
- Disable / enable logging: `$auditEnabled = false`
- Turn off logging for specific fields: `$dontKeepLogOf = ['field1', 'field2']`

```
// app/Team.php
namespace App;

use Illuminate\Database\Eloquent\Model;

class Team extends Model
{
    use Roketin\Auditing\AuditingTrait;
    // Disables the log record in this model.
    protected $auditEnabled  = false;
    // Disables the log record after 500 records.
    protected $historyLimit = 500;
    // Fields you do NOT want to register.
    protected $dontKeepLogOf = ['created_at', 'updated_at'];
    // Tell what actions you want to audit.
    protected $auditableTypes = ['created', 'saved', 'deleted'];
}
```

### Auditing settings

[](#auditing-settings)

Using the configuration file, you can define:

- The Model used to represent the current user of application.
- A different database connection for audit.
- The table name used for log registers.

The configuration file can be found at `config/auditing.php`

```
// config/auditing.php
return [

    // Authentication Model
    'model' => App\User::class,

    // Database Connection
    'connection' => null,

    // Table Name
    'table' => 'logs',
];
```

Getting the Logs
----------------

[](#getting-the-logs)

```
// app/Http/Controller/MyAppController.php
namespace App\Http\Controllers;

use App\Team;

class MyAppController extends BaseController
{
    public function index()
    {
        $team = Team::find(1); // Get team
        $team->logs; // Get all logs
        $team->logs->first(); // Get first log
        $team->logs->last();  // Get last log
        $team->logs->find(2); // Selects log
    }
    //...
}
```

Getting logs with user responsible for the change.

```
use Roketin\Auditing\Log;

$logs = Log::with(['user'])->get();
```

or

```
use App\Team;

$logs = Team::logs->with(['user'])->get();
```

> Note: Remember to properly define the user model in the file `config/auditing.php`
>
> ```
> ...
> 'model' => App\User::class,
> ...
> ```

Customizing log message
-----------------------

[](#customizing-log-message)

You can define your own log messages for presentation. These messages can be defined for both the model as well as for each one of fields.The dynamic part of the message can be done by targeted fields per dot segmented as`{object.property.property} or {object.property|Default value} or {object.property||callbackMethod}`.

> Note: This implementation is optional, you can make these customizations where desired.

Set messages to the model

```
// app/Team.php
namespace App;

use Roketin\Auditing\Auditing;

class Team extends Auditing
{
    //...
    public static $logCustomMessage = '{user.name|Anonymous} {type} a team {elapsed_time}'; // with default value
    public static $logCustomFields = [
        'name'  => 'The name was defined as {new.name||getNewName}', // with callback method
        'owner' => [
            'updated' => '{new.owner} owns the team',
            'created' => '{new.owner|No one} was defined as owner'
        ],
    ];

    public function getNewName($log)
    {
        return $log->new['name'];
    }
    //...
}
```

Getting change logs

```
// app/Http/Controllers/MyAppController.php
//...
public function auditing()
{
    $logs = Team::find(1)->logs; // Get logs of team
    return view('auditing', compact('logs'));
}
//...

```

Featuring log records:

```
    // resources/views/my-app/auditing.blade.php
    ...

        @forelse ($logs as $log)

                {{ $log->customMessage }}

                    @forelse ($log->customFields as $custom)
                        {{ $custom }}
                    @empty
                        No details
                    @endforelse

        @empty
            No logs
        @endforelse

    ...

```

Result:

1. Antério Vieira created a team 1 day ago
    - The name was defined as gestao
    - No one was defined as owner
2. Rafael França deleted a team 2 day ago
    - No details
3. ...

Examples
--------

[](#examples)

##### Spark Auditing

[](#spark-auditing)

For convenience we decided to use the [spark](https://github.com/laravel/spark) for this example, the demonstration of auditing is simple and self explanatory. [Click here](https://github.com/roketin/spark-auditing) and see for yourself.

##### Dreams

[](#dreams)

Dreams is a developed api to serve as an example or direction for developers using laravel-auditing. You can access the application [here](https://dreams-.herokuapp.com). The back-end (api) was developed in laravel 5.1 and the front-end (app) in angularjs, the detail are these:

- [Link for application](https://dreams-.herokuapp.com)
- [Source code api-dreams](https://github.com/roketin/api-dreams)
- [Source code app-dreams](https://github.com/roketin/app-dreams)

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

[](#contributing)

Contributions are welcomed; to keep things organized, all bugs and requests should be opened on github issues tab for the main project in the [roketin/laravel-auditing/issues](https://github.com/roketin/laravel-auditing/issues).

All pull requests should be made to the branch Develop, so they can be tested before being merged into the master branch.

Having problems?
----------------

[](#having-problems)

If you are having problems with the use of this package, there is likely someone has faced the same problem. You can find common answers to their problems:

- [Github Issues](https://github.com/roketin/laravel-auditing/issues?page=1&state=closed)

### License

[](#license)

The laravel-audit package is open source software licensed under the [license MIT](http://opensource.org/licenses/MIT)

###  Health Score

33

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 91.6% 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 ~29 days

Recently: every ~48 days

Total

8

Last Release

3657d ago

Major Versions

1.9 → 2.02016-03-17

PHP version history (2 changes)v1.3PHP &gt;=5.3.0

2.0PHP &gt;=5.5.9

### Community

Maintainers

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

---

Top Contributors

[![anteriovieira](https://avatars.githubusercontent.com/u/1490347?v=4)](https://github.com/anteriovieira "anteriovieira (152 commits)")[![raphaelfranca](https://avatars.githubusercontent.com/u/4260727?v=4)](https://github.com/raphaelfranca "raphaelfranca (6 commits)")[![lavieri](https://avatars.githubusercontent.com/u/141413?v=4)](https://github.com/lavieri "lavieri (3 commits)")[![marktinsley](https://avatars.githubusercontent.com/u/303598?v=4)](https://github.com/marktinsley "marktinsley (2 commits)")[![ameoba32](https://avatars.githubusercontent.com/u/7784093?v=4)](https://github.com/ameoba32 "ameoba32 (1 commits)")[![diofreire](https://avatars.githubusercontent.com/u/14809483?v=4)](https://github.com/diofreire "diofreire (1 commits)")[![spyric](https://avatars.githubusercontent.com/u/2044754?v=4)](https://github.com/spyric "spyric (1 commits)")

---

Tags

loglaravelauditingregisterobserveroketin

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/roketin-laravel-auditing/health.svg)

```
[![Health](https://phpackages.com/badges/roketin-laravel-auditing/health.svg)](https://phpackages.com/packages/roketin-laravel-auditing)
```

###  Alternatives

[jackiedo/log-reader

An easy log reader and management tool for Laravel

151365.1k4](/packages/jackiedo-log-reader)[ytake/laravel-fluent-logger

fluent logger for laravel and lumen

62538.4k1](/packages/ytake-laravel-fluent-logger)[kitloong/laravel-app-logger

Laravel log for your application

101.2M6](/packages/kitloong-laravel-app-logger)[melihovv/laravel-log-viewer

A Laravel log viewer

1231.5k1](/packages/melihovv-laravel-log-viewer)

PHPackages © 2026

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