/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = UserTourcompany::find();
     $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;
     }
     $query->andFilterWhere(['id' => $this->id, 'license_no' => $this->license_no, 'effective_date' => $this->effective_date, 'expire_date' => $this->expire_date, 'user_id' => $this->user_id, 'province' => $this->province, 'amphur' => $this->amphur, 'zipcode' => $this->zipcode]);
     $query->andFilterWhere(['like', 'trader_name', $this->trader_name])->andFilterWhere(['like', 'trader_name_en', $this->trader_name_en])->andFilterWhere(['like', 'trader_category', $this->trader_category])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'mobile_no', $this->mobile_no])->andFilterWhere(['like', 'telephone', $this->telephone])->andFilterWhere(['like', 'email', $this->email]);
     return $dataProvider;
 }
Esempio n. 2
0
 protected function findModelUser($id)
 {
     $model = User::findOne($id);
     if ($model->user_type == 2) {
         return $userModel = UserDlt::findOne($id);
     } elseif ($model->user_type == 3) {
         return $userModel = Usercustoms::findOne($id);
     } elseif ($model->user_type == 5) {
         return $userModel = UserTourcompany::findOne($id);
     }
 }
 /**
  * Finds the UserDlt model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return UserDlt the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = UserTourcompany::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }