zing / laravel-eloquent-blameable
Track the creator and updater for Laravel eloquent
3.4.0
2025-02-24 15:37 UTC
Requires
- php: ^8.0
- illuminate/support: ^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0
Requires (Dev)
- mockery/mockery: ~1.3.3 || ^1.4.2
- orchestra/testbench: ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0
- phpunit/phpunit: ^9.3.3 || ^10.0 || ^11.0
README
Requirements
Require Laravel Eloquent Blameable using Composer:
composer require zing/laravel-eloquent-blameable
Usage
<?php use Illuminate\Database\Eloquent\Model; use Zing\LaravelEloquentBlameable\Blameable; class Content extends Model { use Blameable; }
Custom creator key name or updater key name
<?php use Illuminate\Database\Eloquent\Model; use Zing\LaravelEloquentBlameable\Blameable; class Content extends Model { use Blameable; public function getCreatorKeyName(): string { return 'created_by'; } public function getUpdaterKeyName(): string { return 'updated_by'; } }
Model without updater
<?php use Illuminate\Database\Eloquent\Model; use Zing\LaravelEloquentBlameable\Blameable; class Content extends Model { use Blameable; public function getCreatorKeyName(): string { return 'created_by'; } public function getUpdaterKeyName(): ?string { return null; } }
License
Laravel Eloquent Blameable is an open-sourced software licensed under the MIT license.