virtualorz/actionlog

此包最新版本(0.0.9)没有可用的许可信息。

0.0.9 2019-07-03 07:31 UTC

This package is auto-updated.

Last update: 2024-09-29 05:02:37 UTC


README

用于Laravel网站记录CRUD前后值

安装

composer require virtualorz/actionLog

配置

编辑 config/app.php

'providers' => [
    ...
    Virtualorz\ActionLog\ActionLogServiceProvider::class
]

'aliases' => [
    ...
    'ActionLog' => Virtualorz\ActionLog\Facades\ActionLog::class,
]

发布数据

php artisan vendor:publish --provider="Virtualorz\ActionLog\ActionLogServiceProvider"

运行迁移

php artisan migrate --path=/vendor/virtualorz/actionlog/src/migrations

编辑配置

编辑 config/actionLog_logAction ,
为三种类型设置你想要的名字

方法

pushBefore($key, $value)
add before value to object manual, $key for table name, $value for row value
pushAfter($key, $value)
add after value to object manual, $key for table name, $value for row value
save($page,$action,$remark,$object = null,$target_id = null)
save before after value to database,
$page for page name,
$action for action type, the key of log_action,
$remark for remark text,
$object = null for model object , if null will get the before and after value add manual
$target_id = null for modify target id, if null will get the primary if in model object
save the model object before after value to database
logList($page=15)
return the log list result paginate by $page
logContent($id)
return the content HTML of log id=$id,
you can use {!! $RESULT_HTML !!} in blade to show the log content
$RESULT_HTML for logContent() method result

手动添加值的示例

ActionLog::pushBefore('system_permission', system_permission::where('member_id', $request->get('id'))->get());
...
//do some thing
...
ActionLog::pushAfter('system_permission', system_permission::where('member_id', $request->get('id'))->get());

ActionLog::save(Route::getCurrentRoute()->action['parent'],0,'remark text',null,$request->get('id'));

保存模型值的示例

ActionLog::save(Route::getCurrentRoute()->action['parent'],2,'remark text',$system_permission);

中文版本文件

ActionLog : 记录网站每条数据操作记录