This Laravel package automatically logs the currently logged-in user's ID to the created_by
, updated_by
, deleted_by
, and restored_by
fields of your Eloquent models. It also automatically timestamps the restored_at
field when a model is restored. This simplifies the tracking of data modifications and provides valuable auditing capabilities. The package is easy to install and configure, seamlessly integrating with your existing Laravel application.
You can install the package via composer:
composer require jeffersongoncalves/laravel-created-by
Add in columns our table.
Schema::create('posts', function (Blueprint $table) {
$table->createdBy();
$table->updatedBy();
$table->deletedBy();
$table->restoredBy();
$table->restoredAt();
$table->softDeletes();
});
Your model add traits:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use JeffersonGoncalves\CreatedBy\WithCreatedBy;
use JeffersonGoncalves\CreatedBy\WithUpdatedBy;
use JeffersonGoncalves\CreatedBy\WithDeletedBy;
use JeffersonGoncalves\CreatedBy\WithRestoredBy;
use JeffersonGoncalves\CreatedBy\WithRestoredAt;
class Post extends Model
{
use SoftDeletes;
use WithCreatedBy;
use WithUpdatedBy;
use WithDeletedBy;
use WithRestoredBy;
use WithRestoredAt;
}
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.