/**
  * Creates a new Participant model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($meeting_id)
 {
     $mtg = new Meeting();
     $title = $mtg->getMeetingTitle($meeting_id);
     $model = new Participant();
     $model->meeting_id = $meeting_id;
     $model->invited_by = Yii::$app->user->getId();
     // load friends for auto complete field
     $friends = Friend::getFriendList(Yii::$app->user->getId());
     if ($model->load(Yii::$app->request->post())) {
         if (!User::find()->where(['email' => $model->email])->exists()) {
             // if email not already registered
             //  create new user with temporary username & password
             $temp_email_arr[] = $model->email;
             $model->username = Inflector::slug(implode('-', $temp_email_arr));
             $model->password = Yii::$app->security->generateRandomString(12);
             $model->participant_id = $model->addUser();
         } else {
             // add participant from user record
             $usr = User::find()->where(['email' => $model->email])->one();
             $model->participant_id = $usr->id;
         }
         // validate the form against model rules
         if ($model->validate()) {
             // all inputs are valid
             $model->save();
             return $this->redirect(['/meeting/view', 'id' => $meeting_id]);
         } else {
             // validation failed
             return $this->render('create', ['model' => $model, 'title' => $title, 'friends' => $friends]);
         }
     } else {
         return $this->render('create', ['model' => $model, 'title' => $title, 'friends' => $friends]);
     }
 }