action-log
Laravel 5 操作日志记录, (*1)
Installation
{
"require": {
"majikang/action-log": "~1.0"
},
}
or, (*2)
Require this package with composer:, (*3)
composer require majikang/action-log
Update your packages with composer update or install with composer install., (*4)
Usage
Find the providers key in config/app.php and register the ActionLog Service Provider., (*5)
for Laravel 5.1+, (*6)
'providers' => [
majikang\ActionLog\ActionLogServiceProvider::class,
]
Find the aliases key in config/app.php., (*7)
for Laravel 5.1+, (*8)
'aliases' => [
'ActionLog' => luoyangpeng\ActionLog\Facades\ActionLogFacade::class,
]
Configuration
To use your own settings, publish config., (*9)
$ php artisan vendor:publish, (*10)
config/actionlog.php, (*11)
//填写要记录的日志的模型名称
return [
'\App\Models\User',
];
Last Step
$ php artisan migrate, (*12)
Demo
自动记录操作日志,数据库操作需按如下:, (*13)
update
$users = Users::find(1);
$users->name = "admin";
$users->save();
add
$users = new Users();
$users->name = "admin";
$users->save()
delete
Users:destroy(1);
主动记录操作日志, (*14)
use ActionLog;
ActionLog::createActionLog($type,$content);
ActionLog::ApiLog($type,$content,$result);