spatie/eloquent-sortable
Add sortable behavior to Laravel Eloquent models via a trait. Automatically sets an order column on create (max + 1) and provides a scope to retrieve records in the correct order. Ideal for drag-and-drop lists and custom ordering.
Architecture fit: The package uses a non-invasive trait-based approach that integrates seamlessly with Laravel's Eloquent ORM. It leverages standard Laravel patterns (query scopes, events, config files) without requiring architectural changes. The grouping functionality via buildSortQuery provides clean separation for multi-tenant or context-specific sorting.
Integration feasibility: Very high. Installation is trivial via Composer. Implementation requires only adding the trait and interface to models, with minimal configuration. The documentation provides clear examples for all core features and edge cases (e.g., custom order columns, grouping).
Technical risk: Moderate. Latest version (5.0.0+) requires PHP 8.2+ and Laravel 10+, which may conflict with legacy projects. Performance could degrade with very large datasets (>10k records) due to individual row updates during reordering. No built-in transaction handling for concurrent sort operations, risking order inconsistencies during high-write scenarios.
Key questions: What are the current Laravel/PHP versions in production? How many sortable records exist per group? Are there existing concurrent write patterns that might cause race conditions? How critical is real-time sorting consistency for business
How can I help you explore Laravel packages today?