From 78be10c08e3e17a92886b99de43c022d12fcc639 Mon Sep 17 00:00:00 2001 From: Roman Steinberg <roman.accs@gmail.com> Date: Fri, 13 Oct 2017 20:01:49 +0300 Subject: [PATCH] FIX: teachers binding while sync disciplines --- .../application/classes/Controller/Api/V0/StudyPlan.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/~dev_rating/application/classes/Controller/Api/V0/StudyPlan.php b/~dev_rating/application/classes/Controller/Api/V0/StudyPlan.php index 5166f69c3..4a5b95bb2 100644 --- a/~dev_rating/application/classes/Controller/Api/V0/StudyPlan.php +++ b/~dev_rating/application/classes/Controller/Api/V0/StudyPlan.php @@ -103,7 +103,7 @@ class Controller_Api_V0_StudyPlan extends Controller_Handler_Api } else { if ( !isset($discipline->teacherIDs) || (count($discipline->teacherIDs) == 0)) continue; - $lTeacherIDs = $disciplineModel->getTeachers()->as_array(); + $disciplineModel = Model_Discipline::make() ->author($discipline->teacherIDs[0]) ->subject($discipline->subjectID) @@ -111,11 +111,16 @@ class Controller_Api_V0_StudyPlan extends Controller_Handler_Api ->type($discipline->type) ->faculty($facultyID) ->create(); + + $lTeacher = $disciplineModel->getTeachers()->as_array(); + foreach ($lTeacher as $teacher) { + $lTeacherIDs[] = $teacher['ID']; + } } foreach ($lTeacherIDs as $teacherID) { $teacher = Model_Teacher::with($teacherID); - $disciplineModel->bind($teacher ); + $disciplineModel->bind($teacher); } $res[] = (int)$disciplineModel->ID; } -- GitLab