/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params = []) { $query = ClientBeacons::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => self::ITEMS_PER_PAGE], 'sort' => ['attributes' => ['beaconTitle' => ['asc' => [Beacons::tableName() . '.title' => SORT_ASC], 'desc' => [Beacons::tableName() . '.title' => SORT_DESC]], 'created' => ['asc' => ['created' => SORT_ASC], 'desc' => ['created' => SORT_DESC]], 'updated' => ['asc' => ['updated' => SORT_ASC], 'desc' => ['updated' => SORT_DESC]]]]]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->joinWith('beacon', function (ActiveQuery $query) { $query->andFilterWhere('title', $this->beaconTitle); }); $query->andFilterWhere(['id' => $this->id, 'client_id' => $this->client_id, 'beacon_id' => $this->beacon_id]); return $dataProvider; }