コード例 #1
0
 public function actionInsertusereducationinfo()
 {
     $model = new EducationInformation();
     $university = new University();
     $institution = new Institution();
     $course = new Course();
     if ($model->load(\Yii::$app->getRequest()->getBodyParams(), '')) {
         $input = \Yii::$app->getRequest()->getBodyParams();
         //Insert new University if it does not existed
         if (!isset($input['uni_id']) || $input['uni_id'] == null) {
             $university = new University();
             $university->uni_name = $input['uni_name'];
             $university->uni_status = 1;
             if ($university->save()) {
                 $input['uni_id'] = $university->uni_id;
             }
         }
         //Insert new Institution if it does not existed
         if (!isset($input['inst_id']) || $input['inst_id'] == null) {
             $institution = new Institution();
             $institution->inst_name = $input['inst_name'];
             $institution->uni_id = $input['uni_id'];
             $institution->inst_status = 1;
             if ($institution->save()) {
                 $input['inst_id'] = $institution->inst_id;
             }
         }
         //Insert new course if it does not existed
         if (!isset($input['course_id']) || $input['course_id'] == null) {
             $course = new Course();
             $course->course_name = $input['course_name'];
             $course->course_status = 1;
             if ($course->save()) {
                 $input['course_id'] = $course->course_id;
                 $inst_course = new InstitutionCourse();
                 $inst_course->course_id = $input['course_id'];
                 $inst_course->inst_id = $input['inst_id'];
                 $inst_course->save();
             }
         }
         $edu_information = EducationInformation::find()->where(array('inst_id' => $input['inst_id'], 'course_id' => $input['course_id'], 'el_id' => $input['el_id'], 'ei_graduation_year' => $input['ei_graduation_year']))->one();
         if (!$edu_information || $edu_information == null) {
             $model->inst_id = $input['inst_id'];
             $model->course_id = $input['course_id'];
             $model->el_id = $input['el_id'];
             $model->ei_graduation_year = $input['ei_graduation_year'];
             if ($model->save()) {
                 $input['ei_id'] = $model->ei_id;
             }
         } else {
             $input['ei_id'] = $edu_information->ei_id;
         }
         $user_edu = new UserEducation();
         $user_edu->id = $input['pi_id'];
         $user_edu->ei_id = $input['ei_id'];
         $user_edu->save();
         return $user_edu;
     }
 }
コード例 #2
0
ファイル: UserEducation.php プロジェクト: NeroJz/admbackend
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getEi()
 {
     return $this->hasOne(EducationInformation::className(), ['ei_id' => 'ei_id']);
 }
コード例 #3
0
ファイル: Institution.php プロジェクト: NeroJz/admbackend
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getEducationInformations()
 {
     return $this->hasMany(EducationInformation::className(), ['inst_id' => 'inst_id']);
 }
コード例 #4
0
ファイル: UserController.php プロジェクト: NeroJz/admbackend
 public function actionGeteducationdetail($ei_id)
 {
     $result = array();
     $model = new EducationInformation();
     $model = EducationInformation::FindOne($ei_id);
     // $result['uni_id']=$model->uni_id;
     $result['course'] = $model->course;
     $result['institution'] = $model->inst;
     $result['education_level'] = $model->el;
     $result['ei_graduation_year'] = $model->ei_graduation_year;
     return $result;
 }