public function addLearn($params) { $courseLearn = new CourseLearn(); $courseLearn->courseId = $this->id; $courseLearn->userId = $params['userId']; $courseLearn->addTime = time(); $courseLearn->status = $params['status']; if ($courseLearn->save()) { $this->memberNum = $this->studentCount; $this->save(); return $courseLearn; } }