Merge branch 'develop'
This commit is contained in:
@ -34,7 +34,10 @@ class Model extends \Model
|
||||
$changes[$column] = ['column' => $column, 'old' => $old->$column, 'new' => $value];
|
||||
}
|
||||
$action = '[' . get_called_class() . ']';
|
||||
doLog($user, $action, $changes);
|
||||
$this->doLog($user, $action, $changes);
|
||||
}
|
||||
protected function doLog($user, $action, $variables) {
|
||||
App\Service\Register::log($user, $action, $variables);
|
||||
}
|
||||
public function getId()
|
||||
{
|
||||
|
34
common/Service/Register.php
Normal file
34
common/Service/Register.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
namespace App\Service;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Incoviba\common\Registry as RModel;
|
||||
|
||||
class Register
|
||||
{
|
||||
public static function log($user, $action, $variables)
|
||||
{
|
||||
$data = [
|
||||
'user' => $user,
|
||||
'action' => $action,
|
||||
'time' => Carbon::now(config('app.timezone'))->toDateTimeString()//->format('Y-m-d HH:mm:ss')
|
||||
];
|
||||
$registry = model(RModel::class)
|
||||
->where('user', $user)
|
||||
->where('action', $action)
|
||||
->where('time', $data['time'])
|
||||
->findOne();
|
||||
if (!$registry) {
|
||||
$registry = model(RModel::class)->create($data);
|
||||
$registry->save();
|
||||
}
|
||||
foreach ($variables as $data) {
|
||||
$data['registry'] = $registry->id;
|
||||
$log = (new Factory(RegistryData::class))->where($data)->find();
|
||||
if (!$log) {
|
||||
$log = model(RegistryData::class)->create($data);
|
||||
$log->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -5,7 +5,9 @@
|
||||
"require": {
|
||||
"j4mie/paris": "^1.5",
|
||||
"nesbot/carbon": "^2.28",
|
||||
"danielstjules/stringy": "^3"
|
||||
"danielstjules/stringy": "^3",
|
||||
"aldarien/models": "dev-master",
|
||||
"incoviba/auth": "dev-master"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^8.5",
|
||||
@ -23,5 +25,15 @@
|
||||
"Incoviba\\Common\\": "common",
|
||||
"Incoviba\\": "src"
|
||||
}
|
||||
}
|
||||
},
|
||||
"repositories": [
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "//192.168.1.100/git/models.git"
|
||||
},
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "//192.168.1.100/git/auth.git"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
Reference in New Issue
Block a user