authorize('view ai log analysis'); $analysis = Cache::get('ai_log_analysis_result', 'Analysis not generated yet. Click analyze to start.'); return response()->json([ 'status' => 'success', 'analysis' => $analysis, ]); } /** * Trigger a new AI log analysis. */ public function analyze(Request $request) { $this->authorize('view ai log analysis'); // Clear cache to force new analysis Cache::forget('ai_log_analysis_result'); $analysis = $this->analysisService->analyzeRecentLogs(); return response()->json([ 'status' => 'success', 'analysis' => $analysis, ]); } /** * Clear the AI log analysis cache. */ public function clear() { $this->authorize('view ai log analysis'); Cache::forget('ai_log_analysis_result'); return response()->json([ 'status' => 'success', 'message' => 'Analysis cleared successfully', ]); } }