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

65 lines
2.3 KiB
PHP
Raw Normal View History

2024-01-30 10:55:31 +03:00
<?php
2024-02-14 10:29:17 +03:00
namespace App\Http\Controllers\admin;
2024-01-30 10:55:31 +03:00
2024-03-13 14:44:54 +03:00
use App\Enums\ExaminationTypeEnum;
2024-02-14 10:29:17 +03:00
use App\Http\Controllers\Controller;
use App\Models\Admission;
2024-03-13 14:44:54 +03:00
use App\Models\EntranceExamination;
2024-03-05 14:29:18 +03:00
use App\Models\Faculty;
2024-03-07 13:08:28 +03:00
use App\Models\Subject;
2024-01-30 10:55:31 +03:00
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
{
2024-02-14 10:29:17 +03:00
$admissions = Admission::all()->sortBy('position');
return view('menu.reception-screen', compact('admissions'));
2024-01-30 10:55:31 +03:00
}
2024-03-05 14:29:18 +03:00
public function directions()
{
2024-03-07 13:08:28 +03:00
// $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();
2024-03-05 14:29:18 +03:00
$faculties = Faculty::all();
2024-03-13 14:44:54 +03:00
$subjects = EntranceExamination::all()
->select('subject_id', 'subject_type_id', 'examination_type_id')
->where('examination_type_id', '=', ExaminationTypeEnum::Ege->value)
2024-03-13 15:02:39 +03:00
->reduce(function (?array $carry, $subject) {
2024-03-13 14:44:54 +03:00
$id = $subject['subject_id'];
$value = Subject::find($id)->name;
$carry[$id] = $value;
return $carry;
2024-03-13 15:06:56 +03:00
});
2024-03-13 14:44:54 +03:00
// $subjects = EntranceExamination::pluck('name', 'id');
2024-03-05 14:29:18 +03:00
// $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) {
//
// }
// }
//
// }
2024-03-07 13:08:28 +03:00
return view('new-design.bakalavr-special', compact('faculties', 'subjects'));
2024-03-05 14:29:18 +03:00
}
2024-03-06 15:20:16 +03:00
2024-03-07 13:08:28 +03:00
2024-03-06 15:20:16 +03:00
public function calculator($request)
{
return response()->json($request);
}
2024-01-30 10:55:31 +03:00
}