public function actionSend()
 {
     $partner = new PartnerRequest();
     if (Yii::$app->user->isGuest) {
         $user = \Yii::createObject(RegistrationForm::className());
         $profile = \Yii::createObject(Profile::className());
     } else {
         $user = User::findOne(Yii::$app->user->id);
         $profile = Profile::findOne($user->id);
     }
     if (Yii::$app->request->isPost) {
         if (Yii::$app->user->isGuest) {
             if ($user->load(\Yii::$app->request->post())) {
                 $profile->user_id = $user->register();
                 if ($profile->load(Yii::$app->request->post())) {
                     if ($profile->validate()) {
                         $profile->save();
                     }
                 }
             } else {
                 throw new Exception('Registration is failed.');
             }
         }
         $partner->load(Yii::$app->request->post());
         if ($partner->validate()) {
             $partner->sender_id = $profile->user_id;
             $partner->moderation_status = PartnerRequest::STATUS_ON_MODERATION;
             $partner->save();
             $this->trigger(self::EVENT_SEND, new PartnersEvents());
             Yii::$app->getSession()->setFlash('success', \Yii::t('shop', 'Your partner request was successfully sent.'));
             return $this->redirect(Yii::$app->request->referrer);
         }
     }
     $this->registerStaticSeoData();
     return $this->render('send', ['partner' => $partner, 'user' => $user, 'profile' => $profile]);
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getUser()
 {
     return $this->hasOne(User::className(), ['id' => 'user_id']);
 }