/** * @return array */ public static function getListTargets() { $result = []; $targets = Targets::find()->all(); if (isset($targets)) { foreach ($targets as $target) { /** @var $target Targets */ $result[$target->id] = $target->name; } } return $result; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Targets::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, 'value' => $this->value, 'balance' => $this->balance, 'accounts' => $this->accounts, 'user_id' => $this->user_id, 'date' => $this->date, 'order' => $this->order, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'name', $this->name]); $query->orderBy(['order' => SORT_ASC, 'id' => SORT_DESC]); return $dataProvider; }