create([ 'user_id' => auth('api')->id(), 'server_resource_id' => $extra['server_resource_id'] ?? null, 'bastion_account_id' => $extra['bastion_account_id'] ?? null, 'protocol' => $extra['protocol'] ?? null, 'action' => $action, 'requested_at' => now(), 'metadata' => [ 'path' => $request->path(), 'method' => $request->method(), 'client_ip' => $request->ip(), ...($extra['metadata'] ?? []), ], ]); } }