public function getEmailActivity(ClientSurvey $id, Request $request): JsonResponse 	{ 		$clientSurvey = $id;  		$emailActivities = $clientSurvey->emailActivities()->select([ 			'id', 			'user_id', 			'email_type', 			'count', 			'created_at', 		])->includes();  		return DataTables::eloquent($emailActivities) 		->order(function ($query) use ($request) { 			$order_array = $request->get('order') ?? []; 			$columns_array = $request->columns;  			if (!empty($order_array)) { 				foreach (array_column($order_array, 'dir', 'column') as $column_index => $order_direction) { 					$query->orderBy($columns_array[$column_index]['name'], $order_direction); 				} 			} else { 				$query->latest(); 			} 		}) 		->filter(function ($query) use ($request) { 			$search_term = $request->search['value'] ?? null;  			if ($search_term) { 				$query->search($search_term); 			} 		}) 		->addColumn('action', function (EmailActivity $row) { 			$email_type = $row->email_type;  			return __('email-actions.' . $email_type->name(), ['count' => $row->count]); 		}) 		->addColumn('user', function (EmailActivity $row) { 			$user = $row->user;  			$route = $user?->user->getUserEditUrl(); 			$title = $user?->name;  			return '<a href="' . $route . '">' . $title . '</a>'; 		}) 		->rawColumns(['user', 'action']) 		->toJson(); 	}