Wallogit.com
2017 © Pedro Peláez
A laravel package of action log
Laravel 5 操作日志自动记录, (*1)
The ActionLog Service Provider can be installed via Composer by requiring the
arthuryinzhen/php-action-log package and setting the minimum-stability to dev (required for Laravel 5) in your
project's composer.json., (*2)
{
"require": {
"arthuryinzhen/php-action-log": "dev-master"
},
}
or, (*3)
Require this package with composer:, (*4)
composer require luoyangpeng/action-log dev-master
Update your packages with composer update or install with composer install., (*5)
In Windows, you'll need to include the GD2 DLL php_gd2.dll as an extension in php.ini., (*6)
To use the ActionLog Service Provider, you must register the provider when bootstrapping your Laravel application. There are essentially two ways to do this., (*7)
Find the providers key in config/app.php and register the ActionLog Service Provider., (*8)
'providers' => [
// ...
'arthuryinzhen\ActionLog\ActionLogServiceProvider',
]
for Laravel 5.1+, (*9)
'providers' => [
// ...
arthuryinzhen\ActionLog\ActionLogServiceProvider::class,
]
Find the aliases key in config/app.php., (*10)
'aliases' => [
// ...
'ActionLog' => 'arthuryinzhen\ActionLog\Facades\ActionLogFacade',
]
for Laravel 5.1+, (*11)
'aliases' => [
// ...
'ActionLog' => arthuryinzhen\ActionLog\Facades\ActionLogFacade::class,
]
To use your own settings, publish config., (*12)
$ php artisan vendor:publish, (*13)
config/action-log.php, (*14)
return [ //填写要记录的日志的模型名称 'models' => [ '\App\models\User', ], // 填写监视类别, 默认为admin 该参数为auth相关 'guards' => [ 'admin', ], ];
for Laravel 5.1+, (*15)
return [ //填写要记录的日志的模型名称 'models' => [ \App\models\User::class, ], // 填写监视类别, 默认为admin 该参数为auth相关 'guards' => [ 'admin', ], ];
run:
$ php artisan migrate, (*16)
自动记录操作日志,数据库操作需按如下:, (*17)
update $users = Users::find(1); $users->name = "youname"; $users->save(); add $users = new Users(); $users->name = "youname"; $users->save() delete Users:destroy(1);
主动记录操作日志, (*18)
use ActionLog ActionLog::createActionLog($type,$content);