Merge branch 'develop'

This commit is contained in:
2019-12-26 14:57:44 -03:00
3 changed files with 52 additions and 3 deletions

View File

@ -34,7 +34,10 @@ class Model extends \Model
$changes[$column] = ['column' => $column, 'old' => $old->$column, 'new' => $value]; $changes[$column] = ['column' => $column, 'old' => $old->$column, 'new' => $value];
} }
$action = '[' . get_called_class() . ']'; $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() public function getId()
{ {

View 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();
}
}
}
}

View File

@ -5,7 +5,9 @@
"require": { "require": {
"j4mie/paris": "^1.5", "j4mie/paris": "^1.5",
"nesbot/carbon": "^2.28", "nesbot/carbon": "^2.28",
"danielstjules/stringy": "^3" "danielstjules/stringy": "^3",
"aldarien/models": "dev-master",
"incoviba/auth": "dev-master"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^8.5", "phpunit/phpunit": "^8.5",
@ -23,5 +25,15 @@
"Incoviba\\Common\\": "common", "Incoviba\\Common\\": "common",
"Incoviba\\": "src" "Incoviba\\": "src"
} }
} },
"repositories": [
{
"type": "vcs",
"url": "//192.168.1.100/git/models.git"
},
{
"type": "vcs",
"url": "//192.168.1.100/git/auth.git"
}
]
} }