zing / laravel-eloquent-blameable
Track the creator and updater for Laravel eloquent
3.3.0
2024-03-18 14:37 UTC
Requires
- php: ^8.0
- illuminate/support: ^8.0 || ^9.0 || ^10.0 || ^11.0
Requires (Dev)
- mockery/mockery: ~1.3.3 || ^1.4.2
- nunomaduro/larastan: ^1.0 || ^2.0
- orchestra/testbench: ^6.0 || ^7.0 || ^8.0 || ^9.0
- phpunit/phpunit: ^9.3.3 || ^10.0
- zing/coding-standard: ^6.4 || ^7.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.