spatie

spatie/eloquent-sortable

PHP MIT Web Dev

Sortable behaviour for Eloquent models

1.5k stars
138 forks
recent
GitHub

1.5k

Stars

138

Forks

0

Open issues

30

Contributors

5.0.1 21 Feb 2026

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.

Web Dev Library Discovery value: 3/10
Documentation 8/10
Activity 9/10
Community 8/10
Code quality 7/10

Inferred from signals mentioned in the README (tests, CI, type safety) — not a review of the actual code.

Overall score 8/10

AI's overall editorial judgment — not an average of the bars above, can weigh other factors too.

laravel eloquent sorting order-management trait
Actively maintained Well documented MIT licensed Niche/specialized use case Beginner friendly Production ready
Deep Analysis · Based on README and public signals
4d ago

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.

Origin

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.

Growth

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.

In production

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.

Code analysis
Architecture

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.

Tests

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.

Maintenance

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.

Honest verdict

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

Risks
  • 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.
Prediction

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.

0 found this helpful

Newsletter

Get analyses like this every Monday

Free weekly digest of the most interesting open-source discoveries.

Languages

PHP
100%

Information

Language
PHP
License
MIT
Last updated
2w ago
Created
146mo ago
Analyzed with
anthropic/claude-haiku-4-5

Stars over time

Loading…

Contributors over time

Top 100 contributors only — repos with more will plateau at 100.

Loading…

Open issues

No open issues — clean slate.

Open pull requests

No open pull requests.

Similar repos

spatie

spatie/laravel-sluggable

Laravel-sluggable is a Laravel package that automatically generates unique,...

1.6k PHP Web Dev
spatie

spatie/laravel-translatable

A Laravel trait that makes Eloquent models translatable by storing translations...

2.5k PHP Web Dev
spatie

spatie/laravel-tags

A Laravel package that adds tagging capabilities to Eloquent models with a...

1.7k PHP Web Dev
spatie

spatie/laravel-searchable

Laravel Searchable is a Laravel package that enables structured search across...

1.4k PHP Web Dev
spatie

spatie/laravel-model-status

A Laravel package that adds versioned status tracking to Eloquent models with...

1.1k PHP Web Dev
vs. alternatives
spatie/laravel-tags

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.

spatie/laravel-translatable

Larger Spatie package (2,455 stars). Solves multi-language content; sortable solves ordering. Both are Laravel patterns but address unrelated concerns. No direct competition.

Custom order column implementations

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.

Laravel Nova / Spatie Nova packages

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.