コード例 #1
0
 /**
  * Creates a new User model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new User();
     $profile = new Profile();
     $requestId = Yii::$app->request->get('requestId');
     if ($requestId) {
         $request = Request::findOne($requestId);
         $request->fillData($profile);
         $request->fillData($model);
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         $profile->load($_POST);
         $profile->userId = $model->id;
         $profile->save();
         if ($requestId) {
             $request->status = Request::STATUS_DONE;
             $request->userId = $model->id;
             $request->dateActivate = date('Y-m-d H:i:s');
             $request->save(false, ['status', 'userId']);
         }
         return $this->redirect(['index']);
     } else {
         return $this->render('create', ['model' => $model, 'profile' => $profile]);
     }
 }
コード例 #2
0
 /**
  * Finds the Request model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Request the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Request::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }