/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ProviderServices::find();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'provider_id' => $this->provider_id, 'provider_industry_id' => $this->provider_industry_id, 'service_id' => $this->service_id, 'industry_id' => $this->industry_id, 'is_set' => $this->is_set, 'update_time' => $this->update_time]);
     return $dataProvider;
 }
 protected function saveProviderService($user = null, $service = null, $newProvider)
 {
     if ($user and $service) {
         if (!$newProvider and $user->provider and $prs = ProviderServices::find()->where('provider_id=' . $user->provider->id . ' AND service_id=' . $service->id)->all()) {
             return $prs[0];
         } else {
             $proserv = new ProviderServices();
             $proserv->provider_industry_id = $user->provider->industries[0]->id;
             $proserv->provider_id = $user->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');
             if ($proserv->save()) {
                 return $proserv;
             }
             return false;
         }
     }
     return false;
 }
 public function currentProvider($model)
 {
     if ($user = \common\models\User::findOne(Yii::$app->user->id)) {
         $user->is_provider = 1;
         $user->member = 0;
         $user->role = 'provider';
         if ($user->save()) {
             // create temp provider
             $provider = new \common\models\Provider();
             $provider->user_id = $user->id;
             $provider->industry_id = $model->industry_id;
             $provider->loc_id = 1;
             $provider->legal_form = 'freelancer';
             $provider->type = 'service_provider';
             $provider->department_type = 'hq';
             $provider->status = 'inactive';
             $provider->is_active = 0;
             $provider->registration_time = date('Y-m-d H:i:s');
             //$provider->save();
             if ($provider->save()) {
                 // provider Industry
                 if ($providerIndustry = \common\models\ProviderIndustries::findOne($provider->initialIndustry->id)) {
                     $proserv = new \common\models\ProviderServices();
                     $proserv->provider_industry_id = $providerIndustry->id;
                     $proserv->provider_id = $provider->id;
                     $proserv->industry_id = $model->industry_id;
                     $proserv->service_id = $model->id;
                     $proserv->is_set = 1;
                     $proserv->update_time = date('Y-m-d H:i:s');
                     $proserv->save();
                 }
             }
         }
         return $user;
     }
     return false;
 }
Example #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getProviderServices()
 {
     return $this->hasMany(ProviderServices::className(), ['service_id' => 'id']);
 }
Example #5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getProviderService()
 {
     return $this->hasOne(ProviderServices::className(), ['id' => 'provider_service_id']);
 }
 /**
  * Finds the ProviderServices model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return ProviderServices the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = ProviderServices::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getServices()
 {
     return $this->hasMany(ProviderServices::className(), ['provider_industry_id' => 'id']);
 }