public function checkCount(Question $question) { $answers = $question->getAnswers(); $countTrueAnswers = 0; foreach ($answers as $item) { $item->getCorrectly() ? $countTrueAnswers++ : null; } if ($countTrueAnswers > 3) { $this->session->getFlashBag()->add('notice', 'You have to add not more than 3 true answers for question ' . $question->getTextQuestion()); return false; } return true; }