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; } })->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} {$faculty->name} id}{$direction->id }\" aria-controls=\"offcanvasScrolling\" role=\"button\">{$direction->name}
id }{$direction->id}\" aria-labelledby=\"offcanvasScrollingLabel-{$direction->id}{$direction->id}\" style=\"height: 100%; font-family: Geologica-Medium; overflow-y: auto ; background-image: url({$fon_3}); color: #004329\">
{$direction->code}
{$direction->name}

{$direction->description}

Уровень образования: {$direction->educationLevel->name}


Форма обучения: {$direction->educationForm->name}


Бюджетные места: {$direction->budget_places}


Квота: {$direction->quota}


Места на контракт: {$direction->paid_places}


Стоимость платного обучения: {$direction->cost_paid_place}


Период обучения (в годах): {$direction->period}
{$direction->period} "; }; // phpcs:enable $html = $directions->reduce($generateHtml, ''); return response()->json(['html' => $html]); } }