Skip to content

Commit

Permalink
Fix order models
Browse files Browse the repository at this point in the history
  • Loading branch information
ereminmdev committed May 25, 2021
1 parent 04980f2 commit 3ac7239
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions components/Crud.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,12 @@ public function getDataProvider($filterParams = true, $pagination = false, $rela
'class' => 'ereminmdev\yii2\crud\components\Pagination',
'storeKey' => basename($modelClass) . '-per-page',
],
'sort' => [
'defaultOrder' => [
'id' => SORT_DESC,
],
],
]);

if (!empty($dataProvider->sort->getAttributeOrders())) {
$dataProvider->query->orderBy([]);
}

/** @var ActiveQuery $query */
$query = $dataProvider->query;

Expand Down

0 comments on commit 3ac7239

Please sign in to comment.