Esempio n. 1
0
 public function search($params)
 {
     $query = Country::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $query->andFilterWhere([Country::tableName() . '.status' => '1']);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['Id' => $this->Id, 'status' => $this->status, 'createdOn' => $this->createdOn, 'updatedOn' => $this->updatedOn, 'createdBy' => $this->createdBy, 'updatedBy' => $this->updatedBy]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'countryCode', $this->countryCode]);
     return $dataProvider;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Arbiter::find();
     $country = new Country();
     $arbiterTable = Arbiter::tableName();
     $countryTable = Country::tableName();
     $query->joinWith(['country' => function ($query) use($countryTable) {
         $query->from(['country' => $countryTable]);
     }]);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10]]);
     // enable sorting for the related columns
     $addSortAttributes = ["country.name"];
     foreach ($addSortAttributes as $addSortAttribute) {
         $dataProvider->sort->attributes[$addSortAttribute] = ['asc' => [$addSortAttribute => SORT_ASC], 'desc' => [$addSortAttribute => SORT_DESC]];
     }
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(["{$arbiterTable}.id" => $this->id]);
     $query->andFilterWhere(['like', "{$arbiterTable}.name", $this->name])->andFilterWhere(['like', 'country.name', $this->getAttribute('country.name')]);
     return $dataProvider;
 }
Esempio n. 3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Coach::find();
     $country = new Country();
     $coachTable = Coach::tableName();
     $countryTable = Country::tableName();
     $query->joinWith(['country' => function ($query) use($countryTable) {
         $query->from(['country' => $countryTable]);
     }]);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10]]);
     // enable sorting for the related columns
     $addSortAttributes = ["country.name"];
     foreach ($addSortAttributes as $addSortAttribute) {
         $dataProvider->sort->attributes[$addSortAttribute] = ['asc' => [$addSortAttribute => SORT_ASC], 'desc' => [$addSortAttribute => SORT_DESC]];
     }
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(["{$coachTable}.id" => $this->id, 'birthday' => $this->birthday, 'country_id' => $this->country_id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', "{$coachTable}.name", $this->name])->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'position', $this->position])->andFilterWhere(['like', 'notes', $this->notes])->andFilterWhere(['like', 'player_carrer', $this->player_carrer])->andFilterWhere(['like', 'coach_carrer', $this->coach_carrer])->andFilterWhere(['like', 'image', $this->image])->andFilterWhere(['like', 'country.name', $this->getAttribute('country.name')]);
     return $dataProvider;
 }
 /**
  * Display list of countries in json format
  *
  * @param string $q Query for search
  * @return mixed Json data
  */
 public function actionCountryPartList($query = null)
 {
     if ($query == null) {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
     $search = urldecode($query);
     $query = new Query();
     $query->select('id as value, name as text')->from(Country::tableName())->where(['like', 'name', $search])->orderBy(['name' => SORT_ASC])->limit(10);
     $command = $query->createCommand();
     $data = $command->queryAll();
     $out = array_values($data);
     header("Content-type: text/html; charset=utf-8");
     echo Json::encode($out);
 }