Commit fae74d4bdc56c0ffd546fa311d97167edaeaf687

Authored by Yarik
1 parent 06efb823

Order fix

Showing 1 changed file with 30 additions and 21 deletions   Show diff stats
common/models/ProjectSearch.php
... ... @@ -61,39 +61,48 @@
61 61  
62 62 // add conditions that should always apply here
63 63  
64   - $dataProvider = new ActiveDataProvider([
65   - 'query' => $query,
66   - 'sort' => [
67   - 'attributes' => [
68   - 'project_id',
69   - 'date_add',
70   - 'title' => [
71   - 'asc' => [ 'project_lang.title' => SORT_ASC ],
72   - 'desc' => [ 'project_lang.title' => SORT_DESC ],
  64 + $dataProvider = new ActiveDataProvider(
  65 + [
  66 + 'query' => $query,
  67 + 'sort' => [
  68 + 'attributes' => [
  69 + 'project_id',
  70 + 'date_add',
  71 + 'title' => [
  72 + 'asc' => [ 'project_lang.title' => SORT_ASC ],
  73 + 'desc' => [ 'project_lang.title' => SORT_DESC ],
  74 + ],
  75 + ],
  76 + 'defaultOrder' => [
  77 + 'date_add' => SORT_DESC,
73 78 ],
74 79 ],
75   - ],
76   - ]);
  80 + ]
  81 + );
77 82  
78 83 $this->load($params);
79 84  
80   - if(!$this->validate()) {
  85 + if (!$this->validate()) {
81 86 // uncomment the following line if you do not want to return any records when validation fails
82 87 // $query->where('0=1');
83 88 return $dataProvider;
84 89 }
85 90  
86 91 // grid filtering conditions
87   - $query->andFilterWhere([
88   - 'project_id' => $this->project_id,
89   - 'date_add' => $this->date_add,
90   - ]);
  92 + $query->andFilterWhere(
  93 + [
  94 + 'project_id' => $this->project_id,
  95 + 'date_add' => $this->date_add,
  96 + ]
  97 + );
91 98  
92   - $query->andFilterWhere([
93   - 'like',
94   - 'project_lang.title',
95   - $this->title,
96   - ]);
  99 + $query->andFilterWhere(
  100 + [
  101 + 'like',
  102 + 'project_lang.title',
  103 + $this->title,
  104 + ]
  105 + );
97 106  
98 107 return $dataProvider;
99 108 }
... ...