input()['predmets']; $calcultatorSubjects = json_decode($getJSON); $filteredDirectionIds = EntranceExamination::all() ->select("direction_id", "subject_id", "subject_type_id", "examination_type_id") ->where('examination_type_id', '=', ExaminationTypeEnum::Ege->value) ->reduce(function (array $carry, $examine) { [ 'direction_id' => $direction_id, 'subject_id' => $subject_id, 'subject_type_id' => $subject_type_id ] = $examine; $carry[$direction_id][$subject_type_id][] = $subject_id; $carry[$direction_id][$subject_type_id] = array_unique($carry[$direction_id][$subject_type_id]); return $carry; }, []); $result = collect($filteredDirectionIds) ->filter(function ($subjectTypes) use ($calcultatorSubjects) { $requiredSubjects = $subjectTypes[1]; return array_reduce($requiredSubjects, function ($acc, $requiredSubjects) use ($calcultatorSubjects) { if (!in_array($requiredSubjects, $calcultatorSubjects)) { return false; } return $acc; }, true); }) ->filter(function ($subjectTypes) use ($calcultatorSubjects) { if (array_key_exists(2, $subjectTypes)) { $optionalSubjectsInCalculator = collect($subjectTypes[2]) ->filter(fn($optionalSubject) => in_array($optionalSubject, $calcultatorSubjects)); return $optionalSubjectsInCalculator->count() !== 0; } return true; })->map(fn($subjectTypes, $directionId) => $directionId); $directions = Direction::whereIn('id', $result)->get(); $generateHtml = function ($acc, $direction) { $department = Department::find($direction->department_id); $faculty = Faculty::find($department->faculty_id); // phpcs:disable $fon_3 = URL::to('img/front-page/bakalavr-special/fon3_blok.png'); return "{$acc}
{$direction->description}