validate([ 'table_name' => 'required|string', 'record_id' => 'required|numeric', 'column_name' => 'required|string', 'comment' => 'required|string', 'column_value' => 'nullable|string', ]); try { // Create the comment $comment = ColumnComment::create([ 'table_name' => $validated['table_name'], 'record_id' => $validated['record_id'], 'column_name' => $validated['column_name'], 'comment' => $validated['comment'], 'column_value' => $validated['column_value'] ?? null, 'user_id' => u()->id, 'ip_address' => $request->ip(), ]); return response()->json([ 'success' => true, 'message' => 'Comment saved successfully', 'comment' => $comment ]); } catch (\Exception $e) { return response()->json([ 'success' => false, 'message' => 'Failed to save comment: ' . $e->getMessage() ], 500); } } }