コード例 #1
0
 /**
  * Creates a new ProviderIndustries model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new ProviderIndustries();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
コード例 #2
0
 protected function saveProvider($user = null, $service = null)
 {
     if ($user and $service) {
         $provider = new Provider();
         $provider->user_id = $user->id;
         $provider->industry_id = $service->industry_id;
         $provider->loc_id = $user->details->loc_id;
         $provider->legal_form = 'freelancer';
         $provider->type = 'service_provider';
         $provider->department_type = 'hq';
         $provider->status = 'active';
         $provider->registration_time = date('Y-m-d H:i:s');
         if ($provider->save()) {
             $user->is_provider = 1;
             $user->save();
             // provider Contact
             $providerContact = new \common\models\ProviderContact();
             $providerContact->provider_id = $provider->id;
             $providerContact->contact_type = 'e-mail';
             $providerContact->value = $user->email;
             $providerContact->save();
             // provider Industry
             $providerIndustry = new \common\models\ProviderIndustries();
             $providerIndustry->provider_id = $provider->id;
             $providerIndustry->industry_id = $service->industry_id;
             $providerIndustry->main = 1;
             if ($providerIndustry->save()) {
                 $proserv = new \common\models\ProviderServices();
                 $proserv->provider_industry_id = $providerIndustry->id;
                 $proserv->provider_id = $provider->id;
                 $proserv->industry_id = $service->industry_id;
                 $proserv->service_id = $service->id;
                 $proserv->is_set = 1;
                 $proserv->update_time = date('Y-m-d H:i:s');
                 $proserv->save();
             }
             // provider Industry Terms
             $providerIndustryTerm = new \common\models\ProviderIndustryTerms();
             $providerIndustryTerm->provider_industry_id = $providerIndustry->id;
             $providerIndustryTerm->update_time = date('Y-m-d H:i:s');
             $providerIndustryTerm->save();
             // provider Language
             $providerLanguage = new \common\models\ProviderLanguages();
             $providerLanguage->provider_id = $provider->id;
             $providerLanguage->lang_code = 'SR';
             $providerLanguage->save();
             // provider Portfolio
             $providerPortfolio = new \common\models\ProviderPortfolio();
             $providerPortfolio->provider_id = $provider->id;
             $providerPortfolio->name = 'Moj portfolio';
             $providerPortfolio->save();
             // provider Terms
             $providerTerms = new \common\models\ProviderTerms();
             $providerTerms->provider_id = $provider->id;
             $providerTerms->update_time = date('Y-m-d H:i:s');
             $providerTerms->save();
             // provider Notifications
             $providerNotifications = new \common\models\ProviderNotifications();
             $providerNotifications->provider_id = $provider->id;
             $providerNotifications->notification_type = 'matching';
             $providerNotifications->time = date('Y-m-d H:i:s');
             $providerNotifications->save();
             return $proserv;
         }
     }
     return false;
 }