medicivn / eloquent-logger
Installs: 3 787
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 1
Requires
- php: ^8.1
- jenssegers/mongodb: ^3.9
Requires (Dev)
- nunomaduro/collision: ^6.2
- orchestra/testbench: ^7.6
- phpunit/phpunit: ^9.5
README
Automatically update the logger when updating a model.
How to use:
- First, a root node must be initialized in your model's table
- Add
use ActivityLogTrait;
to your eloquent model, example:
use Medicivn\EloquentLogger\ActivityLogTrait; class UserTest extends Model { use HasFactory, ActivityLogTrait; /** * The column need note write the change * * Default: [] */ const LOGGABLE = [ 'name', ]; /** * The model name to record changes * * Default: null */ const MODEL_NAME_LOG = ActivityUserTestLog::class;
Function
writeLog
: write logger when changing data
Notes
- If you are using ActivityLogTrait for MySQL then create a table with the following columns
model_id
url
time
creator
creator_id
action
key
old_value
new_value