当前位置: 首页>>代码示例>>PHP>>正文


PHP Student::load方法代码示例

本文整理汇总了PHP中app\models\Student::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Student::load方法的具体用法?PHP Student::load怎么用?PHP Student::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Student的用法示例。


在下文中一共展示了Student::load方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionCreate

 /**
  * Creates a new Student model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $student = new Student();
     $user = new User();
     $person = new Person();
     if (Yii::$app->request->post()) {
         $params = Yii::$app->request->post();
         $person->load($params);
         $user->load($params);
         $user->password_hash = Yii::$app->getSecurity()->generatePasswordHash($params['User']['password_hash']);
         $student->load($params);
         if ($person->validate() && $user->validate() && $student->validate()) {
             $person->save(false);
             $user->person_id = $person->id;
             $user->register();
             $student->user_id = $user->id;
             $student->save();
             Yii::$app->session->setFlash('success', 'Se envío un correo de confirmación. Por favor verifique su correo electrónico');
             return $this->refresh();
         } else {
             Yii::$app->session->setFlash('danger', 'Ocurrió ff un error al guardar. Vuelve a intentar');
             return $this->refresh();
         }
     } else {
         return $this->render('create', ['student' => $student, 'user' => $user, 'person' => $person]);
     }
 }
开发者ID:RomarioLopezC,项目名称:RobotSS,代码行数:32,代码来源:DefaultController.php

示例2: actionCreate

 /**
  * Creates a new Student model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Student();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:oma378501,项目名称:attendance,代码行数:14,代码来源:StudentController.php

示例3: actionCreate

 public function actionCreate()
 {
     $model = new Student();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $model->birthday = date('Y-m-d', strtotime($model->birthday));
         if ($model->save()) {
             return $this->redirect(Url::to(['/student/view', 'id' => $model->id]));
         }
     }
     return $this->render('create', ['model' => $model]);
 }
开发者ID:ustkirill,项目名称:testwork,代码行数:11,代码来源:StudentController.php

示例4: actionRegister

 public function actionRegister($co = null, $cl = null)
 {
     $model = new Student();
     if ($model->load(Yii::$app->request->post())) {
         $model->course_id = $co;
         $model->classid = $cl;
         $model->created_dt = date('Y-m-d H:i:s');
         $model->save();
         return $this->redirect(['success']);
         //return $this->redirect(['view', 'id' => $model->id]);
     } else {
         if (!empty($co)) {
             $courselist = Course::findOne($co);
         }
         return $this->render('register', ['model' => $model, 'courselist' => $courselist]);
     }
 }
开发者ID:kaweesak,项目名称:arit_training,代码行数:17,代码来源:StudentController.php

示例5: actionRegistration

 public function actionRegistration($role = '')
 {
     if (!\Yii::$app->user->isGuest) {
         $this->redirect(\Yii::$app->user->getReturnUrl());
     }
     if ($role == '') {
         return $this->render('registration');
     }
     $model = new User();
     $role_model = new Company();
     $model->role = User::ROLE_COMPANY;
     if ($role != 'company') {
         //Student registration
         $role = 'student';
         $role_model = new Student();
         $model->role = User::ROLE_STUDENT;
     }
     if ($model->load(Yii::$app->request->post()) && $role_model->load(Yii::$app->request->post()) && $model->register()) {
         if ($role == 'student') {
             $role_model->idUser = $model->id;
             if ($role_model->save()) {
                 return $this->render('registration_student_success', ['model' => $model]);
             }
         } else {
             $role_model->idUser = $model->id;
             //Upload logo
             if (isset($_FILES['Company']) && $_FILES['Company']['name']['logo_path'] != "") {
                 if (!in_array($_FILES['Company']['type']['logo_path'], $this->image_array)) {
                     $role_model->addError('logo_path', 'Доступные расширения для файла: jpg, gif, png.');
                 } else {
                     $rnd = rand(0, 9999);
                     $uploadedFile = UploadedFile::getInstance($role_model, 'logo_path');
                     $fileName = 'files/' . $rnd . '_' . $uploadedFile->name;
                     $role_model->logo_path = $fileName;
                     $uploadedFile->saveAs($fileName);
                 }
             }
             if ($role_model->save()) {
                 return $this->render('registration_company_success', ['model' => $model]);
             }
         }
     }
     return $this->render('registration_' . $role, ['model' => $model, 'role_model' => $role_model]);
 }
开发者ID:Sywooch,项目名称:RabotaNURE,代码行数:44,代码来源:SiteController.php

示例6: actionCreate

 /**
  * Creates a new Student model.
  * If creation is successful, the browser will be redirected to the either
  * the index or the create page to add another.
  * @return mixed
  */
 public function actionCreate()
 {
     $transaction = Yii::$app->db->beginTransaction();
     // Get the user's school and the current date.
     $schoolId = Yii::$app->user->schoolId;
     $today = date('Y-m-d');
     $student = new Student();
     $student->contract_school_id = $schoolId;
     $student->start_date = $today;
     if ($student->load(Yii::$app->request->post()) && $student->save()) {
         // Affiliate the new student with the same school as the user
         $role = Role::find()->where(['like', 'name', 'student'])->one();
         $affiliation = new Affiliation();
         if ($affiliation->load(Yii::$app->request->post())) {
             $affiliation->student_id = $student->id;
             $affiliation->school_id = $schoolId;
             $affiliation->role_id = $role->id;
             $affiliation->date = $today;
             $affiliation->save();
         }
         /* Get the phone # that was posted along with the new student,
          * and assign it to the student via the newly-created ID.
          */
         $phone = new StudentPhone();
         if ($phone->load(Yii::$app->request->post())) {
             $phone->student_id = $student->id;
             $phone->save();
         }
         if ($affiliation->isSaved && $phone->isSaved) {
             $transaction->commit();
             $url = Html::a($student->name, ['update', 'id' => $student->id]);
             Yii::$app->session->setFlash('success', 'Student added: ' . $url);
             if (Yii::$app->request->post('then-add') !== null) {
                 return $this->redirect(['create']);
             } elseif (Yii::$app->request->post('then-edit') !== null) {
                 return $this->redirect(['update', 'id' => $student->id]);
             } else {
                 return $this->redirect(['index']);
             }
         } else {
             $transaction->rollBack();
             $msg = 'Unable to create student: ';
             //!!! find a better way to extract the model errors
             $msg .= serialize($affiliation->errors);
             $msg .= serialize($phone->errors);
             Yii::$app->session->setFlash('error', $msg);
         }
     }
     return $this->render('create', ['model' => $student]);
 }
开发者ID:NewPaltzKarateAcademy,项目名称:KIMS,代码行数:56,代码来源:StudentController.php


注:本文中的app\models\Student::load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。