skore-labs/laravel-auditable
| Install | |
|---|---|
composer require skore-labs/laravel-auditable |
|
| Latest Version: | 3.1.1 |
| PHP: | ^8.2 || ^8.3 || ^8.4 |
| Laravel: | 11 · 12 · 13 |
| Older releases: | 5 – 10 |
| License: | MIT |
| Last Updated: | Apr 15, 2026 |
| Links: | GitHub · Packagist |
Laravel Auditable
Audit the users that performs actions to your application models
Status
Getting started
composer require skore-labs/laravel-auditable
And write this on the models you want to have auditables:
<?php
namespace SkoreLabs\LaravelAuditable\Tests\Fixtures;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use SkoreLabs\LaravelAuditable\Traits\Auditable;
class Post extends Model
{
use Auditable;
// Add this one and it will auto-detect for the deletedBy
// use SoftDeletes;
/**
* The attributes that should be visible in serialization.
*
* @var array
*/
protected $visible = ['title', 'content'];
}
And this is how it should look like in your migration file:
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreatePostsTestTable extends Migration
{
public function up()
{
Schema::create('posts', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('title');
$table->text('content');
$table->timestamps();
$table->softDeletes();
$table->auditables();
// or if has softDeletes (deleted_at column):
$table->auditables(true);
// also you might want to rename the users table:
$table->auditables(true, 'my_users_table');
});
}
public function down()
{
Schema::dropIfExists('posts');
}
}
Note: If you wanna remove it on the down method of your migrations, you can use dropAuditables.
public function down()
{
Schema::table('posts', function (Blueprint $table) {
$table->dropAuditables();
// or if has softDeletes (deleted_at column):
$table->dropAuditables(true);
});
}
Methods
These are all the relationships that the Auditable trait provides to your model:
$post = Post::first();
$post->createdBy; // Author of the post
$post->updatedBy; // Author of the last update of the post
$post->deletedBy; // Author of the deletion of the post
$post->author; // Alias for createdBy
Support
This and all of our Laravel packages follows as much as possibly can the LTS support of Laravel.
Read more: https://laravel.com/docs/master/releases#support-policy
Credits
- Ruben Robles (@d8vjork)
- Skore (https://www.getskore.com/)
- And all the contributors
Related Packages
Powerful PHP database abstraction layer (DBAL) with many features for database s...
Laravel Serializable Closure provides an easy and secure way to serialize closur...
Cli error handling for console/command-line PHP applications.
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| 3.1.1 | ^8.2 || | ^11.0 || | MIT | |
| 3.1.0 | ^8.2 || | ^11.0 || | MIT | |
| 3.0.0 | ^8.2 | ^11.0 || | MIT | |
| 2.6.0 | ^8.0 | ^9.0 || | MIT | |
| 2.5.2 | ^8.0| | ^9.0| | MIT | |
| 2.5.1 | ^8.0| | ^9.0| | MIT | |
| 2.5.0 | ^8.0| | ^9.0| | MIT | |
| 2.4.0 | ^8.0| | ^9.0| | MIT | |
| 2.3.2 | ^7.2| | ^6.0| | MIT | |
| 2.3.1 | ^7.2| | ^6.0| | MIT | |
| 2.3.0 | ^7.2| | ^6.0| | MIT | |
| 2.2.1 | ^7.2| | ^6.0| | MIT | |
| 2.2.0 | ^7.2| | ^6.0| | MIT | |
| 2.1.0 | ^7.2| | 8.* | MIT | |
| 2.0.1 | ^7.2| | ^6.0| | MIT | |
| 2.0.0 | ^7.2 | ^6.0| | MIT | |
| 1.0.1 | ^7.2 | ~5.5.0| | MIT | |
| 1.0.0 | ^7.2 | ~5.5.0| | MIT |