diff --git a/src/ColumnSortable/SortableLink.php b/src/ColumnSortable/SortableLink.php index 986b0f2..8ce8cab 100644 --- a/src/ColumnSortable/SortableLink.php +++ b/src/ColumnSortable/SortableLink.php @@ -252,7 +252,14 @@ private static function buildQueryString($queryParameters, $sortParameter, $dire }; $persistParameters = array_filter(request()->except('sort', 'direction', 'page'), $checkStrlenOrArray); - $queryString = http_build_query(array_merge($queryParameters, $persistParameters, [ + if (config('columnsortable.swap_querystring_params') == false) { + $parameters[0] = $queryParameters; + $parameters[1] = $persistParameters; + } else { + $parameters[0] = $persistParameters; + $parameters[1] = $queryParameters; + } + $queryString = http_build_query(array_merge($parameters[0], $parameters[1], [ 'sort' => $sortParameter, 'direction' => $direction, ])); diff --git a/src/config/columnsortable.php b/src/config/columnsortable.php index 51b54b9..f4cb7aa 100755 --- a/src/config/columnsortable.php +++ b/src/config/columnsortable.php @@ -118,4 +118,14 @@ for more information see https://github.com/Kyslik/column-sortable/issues/59 */ 'join_type' => 'leftJoin', + + /* + SortableLink.php:buildQueryString() + + when building sortable links, pass the parameters like this if false (default): + array_merge($persistParameters, $queryParameters, + otherwise swap the order + array_merge($queryParameters, $persistParameters, + */ + 'swap_querystring_params' => false, ];