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

54 lines
1.7 KiB
PHP

<?php
namespace App\Http\Controllers\admin;
use App\Enums\FacultyEnum;
use App\Http\Controllers\Controller;
use App\Models\Admission;
use App\Models\Direction;
use App\Models\Faculty;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Foundation\Application;
use Illuminate\Support\Facades\DB;
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();
// $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'));
}
public function calculator($request)
{
return response()->json($request);
}
}