/**
  * Creates a new Participant model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Participant();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 /**
  * Creates a new Participant model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  *
  * @param integer $type
  *
  * @return mixed
  * @throws NotFoundHttpException
  */
 public function actionRegister($type = null)
 {
     if (!\Yii::$app->user->isGuest && !\Yii::$app->user->can('manageUsers')) {
         return $this->redirect(['site/index']);
     }
     $model = new Participant();
     if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->user->login($model->user, 3600 * 24 * 30);
         return $this->redirect(['site/verify']);
     } else {
         $model->setUserType($type);
         $model->scenario = 'register' . $model->getUserType();
         return $this->render('create', ['model' => $model]);
     }
 }