From fae74d4bdc56c0ffd546fa311d97167edaeaf687 Mon Sep 17 00:00:00 2001 From: Yarik Date: Thu, 22 Jun 2017 16:15:30 +0300 Subject: [PATCH] Order fix --- common/models/ProjectSearch.php | 51 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/common/models/ProjectSearch.php b/common/models/ProjectSearch.php index 262c79b..c4928a7 100755 --- a/common/models/ProjectSearch.php +++ b/common/models/ProjectSearch.php @@ -61,39 +61,48 @@ // add conditions that should always apply here - $dataProvider = new ActiveDataProvider([ - 'query' => $query, - 'sort' => [ - 'attributes' => [ - 'project_id', - 'date_add', - 'title' => [ - 'asc' => [ 'project_lang.title' => SORT_ASC ], - 'desc' => [ 'project_lang.title' => SORT_DESC ], + $dataProvider = new ActiveDataProvider( + [ + 'query' => $query, + 'sort' => [ + 'attributes' => [ + 'project_id', + 'date_add', + 'title' => [ + 'asc' => [ 'project_lang.title' => SORT_ASC ], + 'desc' => [ 'project_lang.title' => SORT_DESC ], + ], + ], + 'defaultOrder' => [ + 'date_add' => SORT_DESC, ], ], - ], - ]); + ] + ); $this->load($params); - if(!$this->validate()) { + 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([ - 'project_id' => $this->project_id, - 'date_add' => $this->date_add, - ]); + $query->andFilterWhere( + [ + 'project_id' => $this->project_id, + 'date_add' => $this->date_add, + ] + ); - $query->andFilterWhere([ - 'like', - 'project_lang.title', - $this->title, - ]); + $query->andFilterWhere( + [ + 'like', + 'project_lang.title', + $this->title, + ] + ); return $dataProvider; } -- libgit2 0.21.4