fix new logic to calculator with required and optional subjects
This commit is contained in:
parent
077eda117f
commit
68ccbf2910
|
@ -2,12 +2,12 @@
|
|||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Enums\ExaminationTypeEnum;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Department;
|
||||
use App\Models\Direction;
|
||||
use App\Models\EntranceExamination;
|
||||
use App\Models\Faculty;
|
||||
use App\Models\SubjectType;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
|
||||
|
@ -20,7 +20,8 @@ class CalculatorController extends Controller
|
|||
$countUserSubjects = count($calcultatorSubjects);
|
||||
|
||||
$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) {
|
||||
|
||||
[
|
||||
|
@ -46,11 +47,10 @@ class CalculatorController extends Controller
|
|||
})
|
||||
->filter(function ($subjectTypes) use ($calcultatorSubjects) {
|
||||
$optionalSubjectsInCalculator = collect($subjectTypes[2])
|
||||
->filter(fn ($optionalSubject) => in_array($optionalSubject, $calcultatorSubjects));
|
||||
->filter(fn($optionalSubject) => in_array($optionalSubject, $calcultatorSubjects));
|
||||
return $optionalSubjectsInCalculator->count() !== 0;
|
||||
})->map(fn ($subjectTypes, $directionId) => $directionId)
|
||||
;
|
||||
// dd($result);
|
||||
})->map(fn($subjectTypes, $directionId) => $directionId);
|
||||
|
||||
$directions = Direction::whereIn('id', $result)->get();
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue