Sortable behaviour for Eloquent models
1.5k
Stars
138
Forks
0
Open issues
30
Contributors
AI Analysis
A PHP trait that adds sortable behavior to Laravel Eloquent models, automatically managing an order column for records. Designed specifically for Laravel developers who need drag-and-drop or list-reordering functionality in their applications; not useful outside the Laravel ecosystem.
Inferred from signals mentioned in the README (tests, CI, type safety) — not a review of the actual code.
AI's overall editorial judgment — not an average of the bars above, can weigh other factors too.
Lightweight PHP trait for automatic model ordering in Laravel Eloquent
eloquent-sortable is a small Spatie package that adds automatic ordering behavior to Laravel Eloquent models via a trait. It manages an order column, auto-increments on model creation, and provides query scopes and batch reordering methods. Used primarily by Laravel developers who need drag-and-drop sorting or sequential ordering on collections. Adoption appears moderate and stable within the Laravel ecosystem, with consistent maintenance but modest recent growth.
Created in 2014, this package evolved alongside Laravel's ORM framework. It represents a common pattern in web development: managing model sort order without external dependencies. Spatie, a Belgian web agency, maintains it as part of their broader Laravel ecosystem contributions.
The package gained steady adoption from 2014–2020, reaching ~1,500 stars and establishing itself as a standard solution for Eloquent sorting. Recent growth has plateaued (1 star in last 7 days as of 2026-07-06), suggesting market saturation or that most adopters are pre-existing. Consistent maintenance and Laravel version compatibility updates have kept it relevant rather than driving new adoption.
Adoption not verified through direct evidence in repository metadata. However, Packagist download metrics are referenced via badge, and Spatie's reputation as a trusted Laravel vendor suggests real-world usage. No explicit case studies, testimonials, or production deployment details appear in README. Adoption likely exists but scale and scope cannot be quantified from available data.
Based on README, the package uses a trait-based pattern (`SortableTrait`) that implementers mix into Eloquent models. It appears to rely on a database order column, hooks into model lifecycle events (likely via `creating` listeners), and provides static methods like `setNewOrder()` and `setNewOrderByCustomColumn()` for batch operations. Configuration is exposed via a config file with sensible defaults (`order_column_name`, `sort_when_creating`). No dependency injection or container configuration is mentioned, suggesting a lightweight, procedural design.
README includes GitHub Actions badge indicating automated tests run, but test coverage details are not documented in the excerpt. Test quality and scope cannot be assessed from available information.
Last push 2026-06-26, approximately 10 days before analysis date — active within the evaluation window. Project uses GitHub Actions for CI/CD. No mention of open issues or recent breaking changes in README. Version history suggests ongoing compatibility with modern Laravel (6.x+) and PHP 7.x+. Maintenance appears light but consistent rather than reactive.
ADOPT IF: you are building a Laravel application requiring automatic or user-managed model ordering (e.g., drag-and-drop sorting, menu hierarchies), already trust Spatie packages, and want to avoid custom ordering logic. AVOID IF: you need cross-database ordering, advanced sorting constraints, or plan to migrate away from Eloquent; if your sorting is infrequent or already handled by timestamps/status columns. MONITOR IF: you are evaluating it for a new project — maintenance is stable and it solves a real problem, but adoption is not accelerating and you should confirm it integrates well with your specific UI framework.
Independent dimensions
Mainstream potential
3/10
Technical importance
5/10
Adoption evidence
4/10
- Adoption is not publicly verified — evidence of real-world usage exists but is not explicit in repository metadata. Relying on indirect signals (Packagist downloads, Spatie reputation) introduces uncertainty.
- Package depends on a single order column paradigm. Complex sorting requirements (multi-level hierarchies, conditional ordering, time-based sort buckets) may require custom extensions or abandonment of the trait.
- Tight coupling to Eloquent and Laravel versions. Major Laravel version breaks could require package updates. Migration to non-Eloquent ORMs is not possible without rewriting.
- No evidence of alternative implementations or competing standards. If this package stagnates, there may be limited community alternatives to switch to.
- Auto-increment order assignment on create can cause issues if records are frequently soft-deleted or if ordering must be deterministic across time zones — edge cases likely not covered in default configuration.
This package will remain a stable, niche utility within the Laravel ecosystem. Adoption will likely plateau or decline slowly as Laravel moves toward native ORM features or as developers implement custom solutions. Spatie will maintain it for existing users but it is unlikely to drive new adoption. It occupies a permanent, small niche rather than growing toward mainstream.
Newsletter
Get analyses like this every Monday
Free weekly digest of the most interesting open-source discoveries.
Languages
Information
- Language
- PHP
- License
- MIT
- Last updated
- 2w ago
- Created
- 146mo ago
- Analyzed with
- anthropic/claude-haiku-4-5
Stars over time
Contributors over time
Top 100 contributors only — repos with more will plateau at 100.
Open issues
No open issues — clean slate.
Open pull requests
No open pull requests.
Top contributors
Recent releases
Similar repos
spatie/laravel-sluggable
Laravel-sluggable is a Laravel package that automatically generates unique,...
spatie/laravel-translatable
A Laravel trait that makes Eloquent models translatable by storing translations...
spatie/laravel-searchable
Laravel Searchable is a Laravel package that enables structured search across...
| Repository | Stars | Week Δ | Language | Score | Updated |
|---|---|---|---|---|---|
|
|
1.5k | — | PHP | 8/10 | 2w ago |
|
|
1.6k | — | PHP | 8/10 | 2w ago |
|
|
2.5k | — | PHP | 8/10 | 2w ago |
|
|
1.7k | — | PHP | 8/10 | 2w ago |
|
|
1.4k | — | PHP | 8/10 | 5mo ago |
|
|
1.1k | — | PHP | 8/10 | 1mo ago |
Similar Spatie package (1,744 stars vs. 1,515). Tags solve tagging/classification; sortable solves order management. Both trait-based, both actively maintained. Not direct competitors — complementary problems.
Larger Spatie package (2,455 stars). Solves multi-language content; sortable solves ordering. Both are Laravel patterns but address unrelated concerns. No direct competition.
Many Laravel teams implement ordering logic directly in models or services. eloquent-sortable provides encapsulation and reusability versus bespoke code. Trade-off: convenience vs. lock-in to package patterns.
Nova is Laravel's admin panel. Separate packages handle drag-drop ordering in admin UIs. eloquent-sortable is backend logic; Nova integration is a separate layer. Complementary, not competitive.
