zing / laravel-eloquent-blameable
追踪 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
要求
使用 Composer 安装 Laravel Eloquent Blameable
composer require zing/laravel-eloquent-blameable
用法
<?php use Illuminate\Database\Eloquent\Model; use Zing\LaravelEloquentBlameable\Blameable; class Content extends Model { use Blameable; }
自定义创建者键名或更新者键名
<?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'; } }
没有更新者的模型
<?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; } }
许可证
Laravel Eloquent Blameable 是一个开源软件,受MIT 许可证许可。