forked from aslan/applicant-site
prodV1 #2
|
@ -17,7 +17,6 @@ class CalculatorController extends Controller
|
|||
{
|
||||
$getJSON = $request->input()['predmets'];
|
||||
$calcultatorSubjects = json_decode($getJSON);
|
||||
$countUserSubjects = count($calcultatorSubjects);
|
||||
|
||||
$filteredDirectionIds = EntranceExamination::all()
|
||||
->select("direction_id", "subject_id", "subject_type_id", "examination_type_id")
|
||||
|
@ -37,18 +36,20 @@ class CalculatorController extends Controller
|
|||
}, []);
|
||||
$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)) {
|
||||
$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) {
|
||||
$optionalSubjectsInCalculator = collect($subjectTypes[2])
|
||||
->filter(fn($optionalSubject) => in_array($optionalSubject, $calcultatorSubjects));
|
||||
return $optionalSubjectsInCalculator->count() !== 0;
|
||||
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();
|
||||
|
|
Loading…
Reference in New Issue