Skip to content

Record created by, updated by and deleted by on Eloquent models automatically.

License

Notifications You must be signed in to change notification settings

qtsolv/laravel-auditors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

quarks/laravel-auditors

Record created by, updated by and deleted by (if SoftDeletes added) on Eloquent models automatically.

Latest Version Downloads PHP Version License

Installation

composer require quarks/laravel-auditors

Usage

In your migration classes, add the auditor columns to your table as below:

/**
 * Run the migrations.
 *
 * @return void
 */
public function up()
{
    Schema::table('users', function (Blueprint $table) {
        $table->auditors();
    });
}

/**
 * Reverse the migrations.
 *
 * @return void
 */
public function down()
{
    Schema::table('users', function (Blueprint $table) {
        $table->dropAuditors();
    });
}

Then add the HasAuditors trait your model classes as follows:

namespace App\Models;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Quarks\Laravel\Auditors\HasAuditors;

class User extends Authenticatable
{
    use HasAuditors;
}

From now onwards, createdBy, updatedBy and deletedBy relations on this model will automatically be saved on created, updated and deleted model events respectively.

License

See LICENSE file.

About

Record created by, updated by and deleted by on Eloquent models automatically.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages