From c14e9123c330919dd9cc1a18325a4c5abfe960bd Mon Sep 17 00:00:00 2001 From: Mathieu Leblond Date: Mon, 24 Feb 2020 16:25:06 -0500 Subject: [PATCH 1/4] Update SortableLink.php Updated Query String to override properly the given Get variables rather than ignoring them. --- src/ColumnSortable/SortableLink.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ColumnSortable/SortableLink.php b/src/ColumnSortable/SortableLink.php index ec7e54a..8614dc5 100644 --- a/src/ColumnSortable/SortableLink.php +++ b/src/ColumnSortable/SortableLink.php @@ -238,7 +238,7 @@ private static function buildQueryString($queryParameters, $sortParameter, $dire }; $persistParameters = array_filter(request()->except('sort', 'direction', 'page'), $checkStrlenOrArray); - $queryString = http_build_query(array_merge($queryParameters, $persistParameters, [ + $queryString = http_build_query(array_merge($persistParameters, $queryParameters, [ 'sort' => $sortParameter, 'direction' => $direction, ])); From 7d533543e077cd034231c836340235dc055a717b Mon Sep 17 00:00:00 2001 From: Robbie Love Date: Wed, 9 Feb 2022 22:02:54 +1000 Subject: [PATCH 2/4] add config to use original order of params that can be swapped --- src/ColumnSortable/SortableLink.php | 9 ++++++++- src/config/columnsortable.php | 10 ++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/ColumnSortable/SortableLink.php b/src/ColumnSortable/SortableLink.php index 8614dc5..4b85478 100644 --- a/src/ColumnSortable/SortableLink.php +++ b/src/ColumnSortable/SortableLink.php @@ -238,7 +238,14 @@ private static function buildQueryString($queryParameters, $sortParameter, $dire }; $persistParameters = array_filter(request()->except('sort', 'direction', 'page'), $checkStrlenOrArray); - $queryString = http_build_query(array_merge($persistParameters, $queryParameters, [ + 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 a49d5c9..d5a7a67 100755 --- a/src/config/columnsortable.php +++ b/src/config/columnsortable.php @@ -113,4 +113,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, ]; From 27f2f6d37cf4d8e43e335d232cec49f5b4f711f6 Mon Sep 17 00:00:00 2001 From: Robbie Love Date: Mon, 30 Mar 2026 20:06:03 +1000 Subject: [PATCH 3/4] Add CLAUDE.md with project guidelines and mandatory rules Co-Authored-By: Claude Opus 4.6 (1M context) --- CLAUDE.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..2e0164d --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,35 @@ +# CLAUDE.md — column-sortable + +## Overview + +Ubiquilife fork of Kyslik's column-sortable. Adds clickable column header sorting to Eloquent queries. Used by Appbase's QoModel to provide automatic table column sorting on every feature's index view. + +## Namespace + +`Kyslik\ColumnSortable` + +## Key Classes + +- **`Sortable`** — Trait for Eloquent models. Adds `scopeSortable()` which reads `sort` and `direction` from the request query string and applies `ORDER BY`. Supports sorting through `BelongsTo` and `HasOne` relationships. +- **`SortableLink`** — Blade helper to render sortable column headers with directional arrows. Usage: `@sortablelink('name', 'Display Name')`. +- **`ColumnSortableServiceProvider`** — Auto-discovered. Publishes config, registers Blade directive. +- **`Exceptions\ColumnSortableException`** — Thrown when an unsortable column is requested. + +## Configuration + +Sortable columns are defined per model via `$sortable` array property. Global config in `config/columnsortable.php`. + +## Testing + +```bash +cd column-sortable && vendor/bin/phpunit +``` + +## Mandatory Rules + +- This is a PRIVATE Ubiquilife package. Changes affect ALL apps. +- NEVER change the `Sortable` trait API or query string parameter names (`sort`, `direction`) — every index view depends on these. +- NEVER change `SortableLink` output HTML without checking Appbase table templates. +- Use British spelling in all text and comments. +- Test before committing. +- One logical change per commit. From 5a11e571921ed8a0fd7c6d9b8476b1f8836953b4 Mon Sep 17 00:00:00 2001 From: Robbie Love Date: Sat, 9 May 2026 02:05:56 +1000 Subject: [PATCH 4/4] chore(deps): widen illuminate constraints to include ^13.0 Co-Authored-By: Claude Opus 4.6 (1M context) --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 0d49bdd..b57d46c 100755 --- a/composer.json +++ b/composer.json @@ -19,8 +19,8 @@ ], "require": { "php": ">=7.2", - "illuminate/support": "5.8.*|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0", - "illuminate/database": "5.8.*|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0" + "illuminate/support": "5.8.*|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0|^13.0", + "illuminate/database": "5.8.*|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0|^13.0" }, "require-dev": { "phpunit/phpunit": "^8.5|^9.5.10|^10.5|^11.5.3",