public function actionRegistration()
 {
     $result = Yii::$app->request;
     $event = $result->post('event');
     if ($event === 'Add_New_User') {
         $newUser = new Registration();
         $newUser->AddNewUser($result->post('name'), $result->post('sec_name'), $result->post('birthday'), $result->post('sex'), $result->post('country'), $result->post('city'), $result->post('phone'), $result->post('e-mail'), $result->post('password'));
         $newUser->save();
         Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
         return array('event' => 'Add_New_User', 'answer' => 'success');
     } else {
         if ($event === 'Check_Phone') {
             Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
             return Registration::Check_Phone($result->post('phone'));
         } else {
             if ($event === 'Check_Email') {
                 Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
                 return Registration::Check_Email($result->post('email'));
             } else {
                 $this->view->registerJsFile('/static/js/validate.min.js', ['depends' => ['yii\\web\\YiiAsset', 'yii\\bootstrap\\BootstrapAsset']]);
                 $this->view->registerJsFile('/static/js/mask.min.js', ['depends' => ['yii\\web\\YiiAsset', 'yii\\bootstrap\\BootstrapAsset']]);
                 $this->view->registerJsFile('/static/js/reg_events.js', ['depends' => ['yii\\web\\YiiAsset', 'yii\\bootstrap\\BootstrapAsset']]);
                 return $this->render('Registration', array());
             }
         }
     }
 }
 public static function Check_Phone($phone)
 {
     $row = Registration::find()->from('users', 'registration')->where(['phone' => $phone])->one();
     return self::returnError($row);
 }