public function getQuestionPercentageDataFilteredByCompanies(Collection $questions, ?string $code, Collection &$companies): void 	{ 		$relevant_count = 10;	// How many of the top companies need data about this particular question  		$companies->each(function (Company $company) use (&$relevant_count, $questions, $code) { 			if ($relevant_count <= 0) { 				return false; 			} 			$relevant_count--;  			$question = $questions->firstWhere('code', $code);  			if (!$question) { 				return collect(); 			}  			$answer_array = [];  			$question->answers()->whereHas('applicant', function ($query) use ($company) { 				$query 				->whereHas('survey', function ($query) { 					$query->where('id', $this->client_survey->id); 				}) 				->whereHas('applicantCompanyPivot', function ($query) use ($company) { 					$query 					->where('rank', 1) 					->where('company_id', $company->id); 				}) 				->available() 				->final(); 			})->get()->each(function (Answer $answer) use (&$answer_array) { 				$answer_value = $answer->answer_value;  				if (is_array($answer_value)) { 					$answer_array = array_merge($answer_array, $answer_value); 				} elseif (is_numeric($answer_value)) { 					$answer_array[] = $answer_value; 				} 			});  			$available_answers = empty($question->getTranslation('available_answers', $this->locale)) ? $question->getDefaultTranslation('available_answers') : $question->getTranslation('available_answers', $this->locale);  			$counted_answers_array = array_count_values($answer_array); 			rsort($counted_answers_array); 			$total_answers_count = array_sum($counted_answers_array); 			$counted_answers_array = collect($counted_answers_array);  			$translated_counted_array = [];  			$total_items_in_collection = $counted_answers_array->count() - 1;  			$counted_answers_array->map(function (int $value, int $key) use ($available_answers, &$translated_counted_array, $total_answers_count, &$total_items_in_collection) { 				$translated_key = $available_answers[$key] ?? ($key);  				if ($total_items_in_collection-- > 0) { 					$translated_counted_array[$translated_key] = round($total_answers_count > 0 ? ($value / $total_answers_count) * 100 : 0); 				} else { 					$translated_counted_array[$translated_key] = 100 - array_sum($translated_counted_array); 				} 			});  			$company->setAppends([ 				$code => collect($translated_counted_array), 			]); 		}); 	}