konsulting/laravel-sorting
konsulting/laravel-sorting adds simple, request-driven sorting to Laravel Eloquent queries. Define sortable columns, read sort parameters from the query string, and keep controllers clean with reusable sorting logic for tables and API endpoints.
composer require (or composer update if already present) and confirm you are on 0.1.11; the fix only matters on Laravel 13 / symfony/http-foundation 7.4, where Request::get() is deprecated.sort query parameter — usually a controller, form request, or a Sortable trait/concern. The package now reads it internally via input(), so any custom code still calling $request->get('sort') should be migrated to $request->input('sort') to stay deprecation-free.?sort=name and ?sort=-created_at, return the sorted collection with pagination, and assert the ordering in a feature test. This proves the happy path before you add allowlists or multi-column sorting.php artisan vendor:publish and set your default sort early — the new fallback behaviour relies on that default being sensible.sort. Keep the parameter name in config so front-end and back-end agree.- prefix (or your configured convention) consistent across Blade tables, Inertia props, and API clients; generate the toggle links from a single helper so the UI and backend never drift.withQueryString() on the paginator so ?sort= survives page changes.sort as nullable|string (plus an in: rule against the allowlist) at the edge. This makes the array-parameter case an explicit 422 in your API rather than a silent fallback.?sort=name, ?sort=-name, an omitted parameter, and ?sort[]=name. The last one is the regression that 0.1.11 fixed — assert it returns the default ordering and a 200, not a 500.->get('sort') and request()->get( and replace with input(). Do this in the same PR as the package bump so deprecation warnings don't linger.Request::get() is deprecated, not removed: existing code keeps working on older Symfony versions, so deprecation logs are the only signal. Run your test suite with deprecations-as-warnings enabled in CI to catch this class of issue early.?sort[]=x returns the default sort instead of a TypeError. That is an improvement, but it means malformed client requests fail quietly — log or validate if you need visibility.id as a tiebreaker.?sort=name,-created_at should be validated and mapped as a whole; don't assume a single column when parsing the string yourself.orderByRaw. Use the package's mapping or an explicit match/array lookup.input() path through future Laravel upgrades.How can I help you explore Laravel packages today?