/** * @return ActiveDataProvider */ public function search() { $query = Request::find(); $sort = new Sort(['attributes' => ['date' => ['asc' => ['date' => SORT_ASC, 'beginTime' => SORT_ASC], 'desc' => ['date' => SORT_DESC, 'beginTime' => SORT_DESC]], 'beginTime']]); $dataProvider = new ActiveDataProvider(['sort' => $sort, 'query' => $query]); if ($this->scenario === self::SCENARIO_SEARCH_SCHEDULE) { $dataProvider->pagination = false; $sort->defaultOrder = ['date' => SORT_DESC, 'beginTime' => SORT_ASC]; } elseif ($this->scenario === self::SCENARIO_SEARCH_PERSONAL) { $dataProvider->pagination = new Pagination(['pageSize' => 20]); $sort->defaultOrder = ['date' => SORT_DESC]; } if (!$this->validate()) { return $dataProvider; } $query->andFilterWhere(['date' => $this->date]); if (is_array($this->participantsId)) { $query->andWhere(['participantsId' => ['$in' => $this->participantsId]]); } if ($this->searchKey !== null) { $query->andWhere(['$or' => [['topic' => ['$regex' => $this->searchKey, '$options' => 'i']], ['note' => ['$regex' => $this->searchKey, '$options' => 'i']]]]); } $query->andFilterWhere(['createdBy' => $this->createdBy]); return $dataProvider; }
public function actionListRequests() { $this->layout = 'request-list-menu'; $dataProvider = new ActiveDataProvider(['query' => Request::find()->where(['rsoAgreement' => ['$ne' => Request::RSO_AGREEMENT_NO_NEED]])->orderBy(['date' => -1])]); return $this->render('list-requests', ['dataProvider' => $dataProvider]); }