public function findById($item, $user, $year) { $training = $this->addTrainingData($user, TrainingModel::byYear($year)); foreach ($training as $course) { foreach ($course['relations'] as $relation) { foreach ($relation as $element) { if ($element['id'] == $item) { return $element; } if ($element['type'] == 'quiz' && starts_with($item, $element['id'])) { foreach ($element['questions'] as $key => $question) { if ($element['id'] . '.' . $key == $item) { return $question; } } } } } } return null; }
private function renderTraining($user) { $training = $this->trainingRepository->addTrainingData($user, TrainingModel::byYear($this->year)); return view($this->year . '.training.content')->with('loggedUser', $user)->with('training', $training); }