Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Larasort Laravel Package

s-damian/larasort

LaraSort is a lightweight Laravel package for adding sortable columns to Eloquent queries and tables. It handles sort parameters, column whitelisting, and direction toggling with minimal configuration, making it easy to build interactive, safe sorting in Blade views and APIs.

View on GitHub
Deep Wiki
Context7

Larasort : Column sorting with Laravel - Eloquent sortable

Frequently asked questions about Larasort
How do I install LaraSort in a Laravel application?
Install it with Composer using composer require s-damian/larasort, then apply the package trait or query scope to the Eloquent models you want to sort. Wire the sort and direction parameters from your request into the query and into your Blade table headers. Check the repository README for the exact trait, scope, and helper names for your installed version.
Does LaraSort protect against SQL injection when sorting columns?
LaraSort is designed around sortable-column whitelisting and direction handling, which is the correct control for user-driven sorting. Before production, confirm that the installed version ignores or rejects columns outside the whitelist rather than passing raw request input to orderBy. Review the package code and add tests for invalid column and direction values.
Which Laravel and PHP versions does LaraSort support?
The package targets Laravel and Eloquent, but the provided context does not enumerate exact Laravel and PHP version constraints. Check composer.json on GitHub or Packagist for the require constraints and any CI matrix before adopting it. Pin a known-good version and treat Laravel major upgrades as compatibility checkpoints.
Can LaraSort handle multi-column sorting, relationship sorting, or default sort?
LaraSort is described as lightweight column sorting with direction toggling, so do not assume advanced sorting features without verification. Check the current README and release notes for multi-column sorting, relationship sorting, and default sort behavior. If you need those features, run a proof of concept on one table or extend the package with your own scope.
Is LaraSort safe to use in production?
Operationally it is low risk because it adds no services, jobs, or storage and only affects query building and table header links. The main production concern is dependency maintenance and Laravel compatibility given the small maintainer base and limited community validation. Pin the version, verify whitelist enforcement, monitor advisories, and keep a fork or in-house replacement contingency.
How do I make table headers sortable in Blade with LaraSort?
Pass sort and direction query parameters into your controller or model query, then use the package's documented Blade helper or directive to render sortable header links. Preserve existing filters and pagination parameters in those links, and toggle direction as documented. Confirm the exact helper syntax in the README for your pinned version.
Does LaraSort work with Livewire, Inertia, or API-only Laravel apps?
LaraSort fits naturally into Laravel applications that use Eloquent and Blade for admin lists, data tables, or report views. For Livewire or Inertia, verify how sort parameters are passed and updated in your components before committing. API-only applications may not need it unless you want a consistent server-side sort contract.
How should I test sorting with LaraSort?
Add feature tests that request your sorted endpoints and assert the resulting order and direction for allowed columns. Include invalid column names, invalid directions, and whitelist behavior so unsafe input cannot reach orderBy. If the package lacks its own tests or CI, your application tests become the safety net.
What are alternatives to LaraSort for sortable Eloquent queries?
You can write a small sortable query scope with a column whitelist and direction mapping in roughly 50 lines, use another maintained Laravel sortable package, or sort client-side for small datasets. LaraSort's value is minimal setup for standard column sorting and direction toggling. Compare that convenience against the cost of owning an in-house scope.
How is LaraSort maintained and what happens if it is abandoned?
The assessment notes a small community, a single maintainer, and 26 GitHub stars, so dependency hygiene and Laravel compatibility tracking matter more than day-to-day operations. The MIT license, small code surface, and simple behavior make the package easy to audit, fork, or reproduce. The worst-case exit is replacing it with an in-house sortable scope without schema or data changes. Assign an owner and record that replacement contingency before broad rollout.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons