Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.05 KB | None | 0 0
  1. /** @var Query $query */
  2.         $query = Storage::find();
  3.  
  4.         $dataProvider = new ActiveDataProvider([
  5.             'query' => $query,
  6.             'pagination' => [
  7.                 'pageSize' => 50,
  8.             ],
  9.             'sort' => [
  10.                 'defaultOrder' => [
  11.                     'abbreviation' => SORT_ASC
  12.                 ],
  13.                 'attributes' => [
  14.                     'id',
  15.                     'status',
  16.                     'name' => [
  17.                         'asc' => [new Expression('LENGTH(name) ASC, name ASC')],
  18.                         'desc' => [new Expression('LENGTH(name) DESC, name DESC')],
  19.                         'default' => SORT_ASC,
  20.                     ],
  21.                     'abbreviation' => [
  22.                         'asc' => [new Expression('LENGTH(abbreviation) ASC, abbreviation ASC')],
  23.                         'desc' => [new Expression('LENGTH(abbreviation) DESC, abbreviation DESC')],
  24.                         'default' => SORT_ASC,
  25.                     ],
  26.                 ]
  27.             ]
  28.         ]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement