From dbcf5d4ee216ac7c2b4e33242a62186712a3fd00 Mon Sep 17 00:00:00 2001 From: dogukanoksuz Date: Fri, 29 Sep 2023 05:59:36 +0000 Subject: [PATCH] feature: Server controller audit loggin --- app/Http/Controllers/API/ServerController.php | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/app/Http/Controllers/API/ServerController.php b/app/Http/Controllers/API/ServerController.php index af4e5937..74c2e9f2 100644 --- a/app/Http/Controllers/API/ServerController.php +++ b/app/Http/Controllers/API/ServerController.php @@ -89,6 +89,19 @@ public function update(Request $request) { ], '', Response::HTTP_FORBIDDEN); } + AuditLog::write( + 'server', + 'update', + [ + 'server_id' => $server->id, + 'server_name' => $server->name, + 'server_ip' => $server->ip_address, + 'new_server_name' => $request->name, + 'new_server_ip' => $request->ip_address + ], + "SERVER_UPDATE" + ); + $server->name = $request->name; $server->ip_address = $request->ip_address; $server->save(); @@ -129,6 +142,16 @@ public function delete(Request $request) { ], '', Response::HTTP_FORBIDDEN); } + AuditLog::write( + 'server', + 'delete', + [ + 'server_id' => $server->id, + 'server_name' => $server->name + ], + "SERVER_DELETE" + ); + $server->delete(); return response()->json([