quarks / laravel-auditors
Record created by, updated by and deleted by on Eloquent models automatically.
Installs: 16 763
Dependents: 2
Suggesters: 0
Security: 0
Stars: 3
Watchers: 0
Forks: 0
Open Issues: 0
Requires
- php: >=7.2
Requires (Dev)
- laravel/framework: ^6.0 || ^7.0 || ^8.0
README
Record created by, updated by and deleted by (if SoftDeletes added) on Eloquent models automatically.
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.