forked from aslan/applicant-site
add groupedDirections array to main page
This commit is contained in:
parent
d5ace86b61
commit
ba9f268ff7
|
@ -47,7 +47,129 @@ class PageController extends Controller
|
||||||
'directions.name',
|
'directions.name',
|
||||||
"educational_institutions.name as educational_institution_name"
|
"educational_institutions.name as educational_institution_name"
|
||||||
]);
|
]);
|
||||||
return view('new-design.bakalavr-special', compact('faculties', 'subjects', 'directionsWithInstitution'));
|
|
||||||
|
$directionsGroups = Direction::with(['department'])
|
||||||
|
->leftJoin('direction_direction_profile', 'directions.id', '=', 'direction_direction_profile.direction_id')
|
||||||
|
->leftJoin(
|
||||||
|
'direction_profiles',
|
||||||
|
'direction_direction_profile.direction_profile_id',
|
||||||
|
'=',
|
||||||
|
'direction_profiles.id'
|
||||||
|
)
|
||||||
|
->leftJoin('departments', 'directions.department_id', '=', 'departments.id')
|
||||||
|
->leftJoin('faculties', 'departments.faculty_id', '=', 'faculties.id')
|
||||||
|
->leftJoin('education_levels', 'directions.education_level_id', '=', 'education_levels.id')
|
||||||
|
->leftJoin('education_forms', 'directions.education_form_id', '=', 'education_forms.id')
|
||||||
|
->leftJoin('entrance_examinations', 'entrance_examinations.direction_id', '=', 'directions.id')
|
||||||
|
->leftJoin(
|
||||||
|
'educational_institutions',
|
||||||
|
'faculties.educational_institution_id',
|
||||||
|
'=',
|
||||||
|
'educational_institutions.id'
|
||||||
|
)
|
||||||
|
->leftJoin('examination_types', 'entrance_examinations.examination_type_id', '=', 'examination_types.id')
|
||||||
|
->leftJoin('subject_types', 'entrance_examinations.subject_type_id', '=', 'subject_types.id')
|
||||||
|
->leftJoin('subjects', 'entrance_examinations.subject_id', '=', 'subjects.id')
|
||||||
|
->select(
|
||||||
|
'directions.id as direction_id',
|
||||||
|
'directions.code as direction_code',
|
||||||
|
'directions.name as direction_name',
|
||||||
|
'directions.description as direction_description',
|
||||||
|
'directions.budget_places as direction_budget_places',
|
||||||
|
'directions.paid_places as direction_paid_places',
|
||||||
|
'directions.cost_paid_place as direction_cost_paid_place',
|
||||||
|
'directions.period as direction_period',
|
||||||
|
'education_levels.name as education_level_name',
|
||||||
|
'education_forms.name as education_form_name',
|
||||||
|
'faculties.id as faculty_id',
|
||||||
|
'faculties.name as faculty_name',
|
||||||
|
'educational_institutions.id as educational_institution_id',
|
||||||
|
'educational_institutions.name as educational_institution_name',
|
||||||
|
'direction_profiles.id as direction_profile_id',
|
||||||
|
'entrance_examinations.scores as entrance_examination_score',
|
||||||
|
'examination_types.name as examination_type_name',
|
||||||
|
'subject_types.name as subject_type_name',
|
||||||
|
'subjects.name as subject_name',
|
||||||
|
'direction_profiles.name as direction_profile_name',
|
||||||
|
)
|
||||||
|
->get()->toArray();
|
||||||
|
|
||||||
|
$branches = [];
|
||||||
|
$directionsGroupWithOutBranch = array_reduce($directionsGroups, function ($acc, $direction) use (&$branches) {
|
||||||
|
|
||||||
|
if ($direction['educational_institution_id'] == 3) {
|
||||||
|
$branches[] = $direction;
|
||||||
|
return $acc;
|
||||||
|
}
|
||||||
|
$acc[] = $direction;
|
||||||
|
return $acc;
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
$groupedDirections = collect($directionsGroupWithOutBranch)
|
||||||
|
->reduce(function ($carry, $item, $key) use ($branches) {
|
||||||
|
[
|
||||||
|
'direction_id' => $directionId,
|
||||||
|
'direction_name' => $directionName,
|
||||||
|
'direction_code' => $directionCode,
|
||||||
|
'educational_institution_id' => $educational_institution_id,
|
||||||
|
'educational_institution_name' => $educationalInstitutionName,
|
||||||
|
'faculty_name' => $facultyName,
|
||||||
|
'education_level_name' => $educationLevelName,
|
||||||
|
'education_form_name' => $educationFormName,
|
||||||
|
'entrance_examination_score' => $entranceExaminationScore,
|
||||||
|
'examination_type_name' => $examinationTypeName,
|
||||||
|
'subject_type_name' => $subjectTypeName,
|
||||||
|
'subject_name' => $subjectName,
|
||||||
|
'direction_profile_name' => $directionProfileName,
|
||||||
|
'direction_budget_places' => $directionBudgetPlaces,
|
||||||
|
'direction_paid_places' => $directionPaidPlaces,
|
||||||
|
'direction_cost_paid_place' => $directionCostPaidPlace,
|
||||||
|
'direction_period' => $directionPeriod,
|
||||||
|
'direction_description' => $directionDescription,
|
||||||
|
] = $item;
|
||||||
|
|
||||||
|
$carry[$facultyName][$directionName]['id'] = $directionId;
|
||||||
|
$carry[$facultyName][$directionName]['code'] = $directionCode;
|
||||||
|
$carry[$facultyName][$directionName]['education_level'] = $educationLevelName;
|
||||||
|
$carry[$facultyName][$directionName]['education_form'][] = $educationFormName;
|
||||||
|
$carry[$facultyName][$directionName]['education_form'] = array_unique(
|
||||||
|
$carry[$facultyName][$directionName]['education_form']
|
||||||
|
);
|
||||||
|
$carry[$facultyName][$directionName]['entrance_examinations']
|
||||||
|
[$examinationTypeName][$subjectTypeName][$subjectName] = $entranceExaminationScore;
|
||||||
|
$carry[$facultyName][$directionName]['budget_places']
|
||||||
|
[$educationalInstitutionName][$directionProfileName][$educationFormName] = $directionBudgetPlaces;
|
||||||
|
|
||||||
|
$carry[$facultyName][$directionName]['paid_places'][$educationFormName] = $directionPaidPlaces;
|
||||||
|
$carry[$facultyName][$directionName]['cost_paid_place'][$educationFormName] = $directionCostPaidPlace;
|
||||||
|
$carry[$facultyName][$directionName]['period'][$educationFormName] = $directionPeriod;
|
||||||
|
$carry[$facultyName][$directionName]['description'] = $directionDescription;
|
||||||
|
|
||||||
|
foreach ($branches as $branch) {
|
||||||
|
[
|
||||||
|
'direction_name' => $directionNameBranch,
|
||||||
|
'educational_institution_name' => $educationalInstitutionNameBranch,
|
||||||
|
'direction_profile_name' => $directionProfileNameBranch,
|
||||||
|
'education_form_name' => $educationFormNameBranch,
|
||||||
|
'direction_budget_places' => $directionBudgetPlacesBranch
|
||||||
|
] = $branch;
|
||||||
|
if ($directionNameBranch === $directionName) {
|
||||||
|
$carry[$facultyName][$directionName]['budget_places']
|
||||||
|
[$educationalInstitutionNameBranch][$directionProfileNameBranch]
|
||||||
|
[$educationFormNameBranch] = $directionBudgetPlacesBranch;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return $carry;
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return view('new-design.bakalavr-special', compact(
|
||||||
|
'faculties',
|
||||||
|
'subjects',
|
||||||
|
'directionsWithInstitution',
|
||||||
|
'groupedDirections'
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue