Browse Source

Log 修正

LD 5 năm trước cách đây
mục cha
commit
e11c3fc03a
1 tập tin đã thay đổi với 10 bổ sung16 xóa
  1. 10 16
      app/Services/LogService.php

+ 10 - 16
app/Services/LogService.php

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