input()['predmets']; $calcultatorSubjects = json_decode($getJSON); $countUserSubjects = count($calcultatorSubjects); $filteredDirectionIds = EntranceExamination::all() ->select("direction_id", "subject_id", "subject_type_id") ->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) { $requiredSbjects = $subjectTypes[1]; return array_reduce($requiredSbjects, function ($acc, $requiredSbject) use ($calcultatorSubjects) { if (!in_array($requiredSbject, $calcultatorSubjects)) { return false; } return $acc; }, true); }) ->filter(function ($subjectTypes) use ($calcultatorSubjects) { $optionalSubjectsInCalculator = collect($subjectTypes[2]) ->filter(fn ($optionalSubject) => in_array($optionalSubject, $calcultatorSubjects)); return $optionalSubjectsInCalculator->count() !== 0; })->map(fn ($subjectTypes, $directionId) => $directionId) ; // dd($result); $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}