prodV1 #2

Open
RomanGolienko wants to merge 309 commits from prodV1 into main
4 changed files with 30 additions and 34 deletions
Showing only changes of commit 08bc93ad2d - Show all commits

View File

@ -4,9 +4,9 @@ on:
push:
branches:
- main
pull_request:
branches:
- main
# pull_request:
# branches:
# - main
jobs:
build:

View File

@ -7,6 +7,7 @@ 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;
@ -15,18 +16,34 @@ class CalculatorController extends Controller
public function findDirectionFromSubjects(Request $request)
{
$getJSON = $request->input()['predmets'];
$getsSubjects = json_decode($getJSON);
$countUserSubjects = count($getsSubjects);
$calcultatorSubjects = json_decode($getJSON);
$countUserSubjects = count($calcultatorSubjects);
$filteredDirectionIds = EntranceExamination::all()
->select("direction_id", "subject_id")
->groupBy('direction_id')
->map(function ($direction) {
return $direction->map(fn($item) => $item['subject_id']);
})
->filter(fn($direction) => count($direction) <= $countUserSubjects)->keys();
->select("direction_id", "subject_id", "subject_type_id")
->reduce(function (array $carry, $examine) {
$directions = Direction::whereIn('id', $filteredDirectionIds)->get();
[
'direction_id' => $direction_id,
'subject_id' => $subject_id,
'subject_type_id' => $subject_type_id
] = $examine;
$carry[$direction_id][$subject_type_id][] = $subject_id;
$carry[$direction_id][$subject_type_id] = array_unique($carry[$direction_id][$subject_type_id]);
return $carry;
}, []);
$result = collect($filteredDirectionIds)
->filter(fn ($subjectTypes) => !array_diff($subjectTypes[1], $calcultatorSubjects))
->filter(function ($subjectTypes) use ($calcultatorSubjects) {
$optionalSubjectsInCalculator = collect($subjectTypes[2])
->filter(fn ($optionalSubject) => in_array($optionalSubject, $calcultatorSubjects));
return $optionalSubjectsInCalculator->count() !== 0;
})->map(fn ($subjectTypes, $directionId) => $directionId)
;
// dd($result);
$directions = Direction::whereIn('id', $result)->get();
$generateHtml = function ($acc, $direction) {

View File

@ -22,12 +22,6 @@ class PageController extends Controller
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();
$subjects = EntranceExamination::all()
->select('subject_id', 'subject_type_id', 'examination_type_id')
@ -38,21 +32,6 @@ class PageController extends Controller
$carry[$id] = $value;
return $carry;
});
// $subjects = EntranceExamination::pluck('name', 'id');
// $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', 'subjects'));
}

View File

@ -495,7 +495,7 @@
$('.text-remove').remove();
let selected = []; let predmets='';
$('.calcul input:checked').each(function() {
selected.push($(this).val());
selected.push(+$(this).val());
predmets += $(this).val()+',';
});