fix new logic to calculator with required and optional subjects

This commit is contained in:
aslan 2024-03-18 11:21:48 +03:00
parent 077eda117f
commit 68ccbf2910
1 changed files with 6 additions and 6 deletions

View File

@ -2,12 +2,12 @@
namespace App\Http\Controllers\Api; namespace App\Http\Controllers\Api;
use App\Enums\ExaminationTypeEnum;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\Department; use App\Models\Department;
use App\Models\Direction; use App\Models\Direction;
use App\Models\EntranceExamination; use App\Models\EntranceExamination;
use App\Models\Faculty; use App\Models\Faculty;
use App\Models\SubjectType;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\URL; use Illuminate\Support\Facades\URL;
@ -20,7 +20,8 @@ class CalculatorController extends Controller
$countUserSubjects = count($calcultatorSubjects); $countUserSubjects = count($calcultatorSubjects);
$filteredDirectionIds = EntranceExamination::all() $filteredDirectionIds = EntranceExamination::all()
->select("direction_id", "subject_id", "subject_type_id") ->select("direction_id", "subject_id", "subject_type_id", "examination_type_id")
->where('examination_type_id', '=', ExaminationTypeEnum::Ege->value)
->reduce(function (array $carry, $examine) { ->reduce(function (array $carry, $examine) {
[ [
@ -46,11 +47,10 @@ class CalculatorController extends Controller
}) })
->filter(function ($subjectTypes) use ($calcultatorSubjects) { ->filter(function ($subjectTypes) use ($calcultatorSubjects) {
$optionalSubjectsInCalculator = collect($subjectTypes[2]) $optionalSubjectsInCalculator = collect($subjectTypes[2])
->filter(fn ($optionalSubject) => in_array($optionalSubject, $calcultatorSubjects)); ->filter(fn($optionalSubject) => in_array($optionalSubject, $calcultatorSubjects));
return $optionalSubjectsInCalculator->count() !== 0; return $optionalSubjectsInCalculator->count() !== 0;
})->map(fn ($subjectTypes, $directionId) => $directionId) })->map(fn($subjectTypes, $directionId) => $directionId);
;
// dd($result);
$directions = Direction::whereIn('id', $result)->get(); $directions = Direction::whereIn('id', $result)->get();