From 1743d102894f4f10e508a8bfdc31b48b72e464b7 Mon Sep 17 00:00:00 2001 From: aslan Date: Wed, 13 Mar 2024 14:44:54 +0300 Subject: [PATCH] fix calculator --- app/Http/Controllers/admin/PageController.php | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/admin/PageController.php b/app/Http/Controllers/admin/PageController.php index e5c21fd..0834b30 100644 --- a/app/Http/Controllers/admin/PageController.php +++ b/app/Http/Controllers/admin/PageController.php @@ -2,16 +2,15 @@ namespace App\Http\Controllers\admin; -use App\Enums\FacultyEnum; +use App\Enums\ExaminationTypeEnum; use App\Http\Controllers\Controller; use App\Models\Admission; -use App\Models\Direction; +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; -use Illuminate\Support\Facades\DB; class PageController extends Controller { @@ -30,7 +29,21 @@ class PageController extends Controller // ->groupBy('faculties.name') // ->get(); $faculties = Faculty::all(); - $subjects = Subject::pluck('name', 'id'); + $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(); + + dd($subjects); +// $subjects = EntranceExamination::pluck('name', 'id'); // $infBez = $faculties->find(FacultyEnum::InfBez->value); // $query = `select faculties.name, directions.name, directions.id //FROM faculties