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} {$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]); } }