|
|
@@ -18,29 +18,23 @@ class LogService
|
|
|
$user = auth()->user();
|
|
|
if ($user) $id_user = $user['id'];
|
|
|
}
|
|
|
+ $log=new Log([
|
|
|
+ 'operation' => $method,
|
|
|
+ 'type' => $type,
|
|
|
+ 'description' => $description,
|
|
|
+ 'id_user' => $id_user,
|
|
|
+ 'ip' => request()->ip(),
|
|
|
+ ]);
|
|
|
try {
|
|
|
Redis::LLEN('LOGS');
|
|
|
} catch (Exception $e) {
|
|
|
//redis出现异常直接保存到数据库中
|
|
|
- (new Log([
|
|
|
- 'operation' => $method,
|
|
|
- 'type' => $type,
|
|
|
- 'description' => $description,
|
|
|
- 'id_user' => $id_user,
|
|
|
- 'ip' => request()->ip(),
|
|
|
- ]))->save();
|
|
|
+ $log->save();
|
|
|
return;
|
|
|
}
|
|
|
$date = date('Y-m-d H:i:s');
|
|
|
- $log = new Log([
|
|
|
- 'operation' => $method,
|
|
|
- 'type' => $type,
|
|
|
- 'description' => $description,
|
|
|
- 'id_user' => $id_user,
|
|
|
- 'ip' => Request::ip(),
|
|
|
- 'created_at' => $date,
|
|
|
- 'updated_at' => $date
|
|
|
- ]);
|
|
|
+ $log['created_at']=$date;
|
|
|
+ $log['updated_at']=$date;
|
|
|
Redis::LPUSH('LOGS', $log);
|
|
|
}
|
|
|
|