Skip to content

Commit

Permalink
feature: Server controller audit loggin
Browse files Browse the repository at this point in the history
  • Loading branch information
dogukanoksuz committed Sep 29, 2023
1 parent 99696cf commit dbcf5d4
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions app/Http/Controllers/API/ServerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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([
Expand Down

0 comments on commit dbcf5d4

Please sign in to comment.