/** * Логика поиска * @param $params * @return ActiveDataProvider */ public function search($params) { $query = Author::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => self::PAGE_SIZE]]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['like', 'firstname', $this->firstname])->andFilterWhere(['like', 'lastname', $this->lastname]); return $dataProvider; }
/** * Метод получения всех авторов * @return array */ protected function getAuthors() { /** @var Author[] $models */ $models = Author::find()->all(); $records = []; if ($models) { foreach ($models as $model) { $records[$model->id] = $model->getFullName(); } } return $records; }