Roman_applicant-site/app/Http/Controllers/admin/PageController.php

69 lines
2.4 KiB
PHP

<?php
namespace App\Http\Controllers\admin;
use App\Enums\ExaminationTypeEnum;
use App\Http\Controllers\Controller;
use App\Models\Admission;
use App\Models\EntranceExamination;
use App\Models\Faculty;
use App\Models\Subject;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Foundation\Application;
class PageController extends Controller
{
public function index(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application
{
$admissions = Admission::all()->sortBy('position');
return view('menu.reception-screen', compact('admissions'));
}
public function directions()
{
// $directions = DB::table('faculties')
// ->join('departments', 'faculties.id', '=', 'departments.faculty_id')
// ->join('directions', 'departments.id', '=', 'directions.department_id')
// ->select('faculties.name as faculties.name', 'directions.name', 'directions.id')
// ->groupBy('faculties.name')
// ->get();
$faculties = Faculty::all();
$subjects = EntranceExamination::all()
->select('subject_id', 'subject_type_id', 'examination_type_id')
->where('examination_type_id', '=', ExaminationTypeEnum::Ege->value)
->groupBy('subject_type_id')->map(function ($examinate) {
return $examinate->reduce(function (?array $carry, $subject) {
$id = $subject['subject_id'];
$value = Subject::find($id)->name;
$carry[$id] = $value;
return $carry;
});
})
->toArray();
// $subjects = EntranceExamination::pluck('name', 'id');
// $infBez = $faculties->find(FacultyEnum::InfBez->value);
// $query = `select faculties.name, directions.name, directions.id
//FROM faculties
//join departments on faculties.id = departments.faculty_id
//join directions on departments.id = directions.department_id`;
// $directions = DB::($query);
// foreach ($faculties as $faculty) {
// foreach ($faculty->departments as $department) {
// foreach ($department->directions as $direction) {
//
// }
// }
//
// }
return view('new-design.bakalavr-special', compact('faculties', 'subjects'));
}
public function calculator($request)
{
return response()->json($request);
}
}