request->getPost(); $chapter = $this->checkChapterCache($id); $user = $this->getLoginUser(); $validator = new LearningValidator(); $data = [ 'course_id' => $chapter->course_id, 'chapter_id' => $chapter->id, 'user_id' => $user->id, 'position' => 0, ]; $data['request_id'] = $validator->checkRequestId($post['request_id']); $data['plan_id'] = $validator->checkPlanId($post['plan_id']); if ($chapter->model == CourseModel::MODEL_VOD) { $data['position'] = $validator->checkPosition($post['position']); } $interval = $validator->checkInterval($post['interval']); $learning = new LearningModel($data); $syncer = new LearningSyncerService(); $syncer->addItem($learning, $interval); } }