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

Laravel Sortable Laravel Package

james.xue/laravel-sortable

Laravel Sortable adds easy drag-and-drop ordering to Eloquent models: define sortable columns, automatically manage positions on create/update/delete, and reorder records with simple query helpers. Ideal for menus, galleries, and any list that needs custom sequencing.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit. This is a single-concern Eloquent behavior package: a trait that maintains a positional column on a model and exposes reordering operations. That shape is architecturally clean — it lives entirely at the persistence layer, has no service-provider-heavy bootstrapping, and imposes no opinion on controllers, APIs, or UI. It is a natural fit anywhere an application models an ordered collection: CMS navigation, category trees, FAQ/banner ordering, ordered lookup tables, workflow step sequences. Because the contract is a trait plus a column, it also composes well with repository/service patterns and does not leak into domain logic.

Integration feasibility. Mechanically trivial: composer require, a migration adding a positional column, and a use statement on the target model. The real feasibility question is not "can we wire it in" but "can we trust it." With 2 stars and 0 dependents, there is effectively no production evidence. Before adoption, a TPM should require a source read of the trait — the entire behavior likely fits in one or two files — plus verification of composer.json constraints against the team's Laravel and PHP versions. A package this small is often faster to audit than to evaluate.

Technical risk. Three risks dominate:

  1. Maintainer/bus-factor risk. One author, negligible adoption, no visible issue traffic. The probability of abandonment is high enough that the package should be treated as a vendored snippet rather than an external dependency.
  2. Reorder correctness under concurrency. Positional-ordering implementations classically suffer race conditions when two users reorder simultaneously, and naive implementations reindex the entire set on every move (O(n) writes) or leave gaps and duplicates. Whether this package uses transactions, a unique composite index, or a gap/fractional strategy must be determined from source.
  3. Scoping semantics. Many apps need ordering within a parent (per-category, per-tenant, per-menu). If the package only supports a global sequence, it will not fit multi-tenant or nested use cases without modification.

Key questions to resolve before commitment.

  • Does it support group-scoped ordering (e.g., orderBy position partitioned by parent_id / tenant_id), or only a global sequence?
  • How are concurrent reorders handled — transaction, row locks, unique constraint, retry?
  • Does a move reindex the full set, or use gap/fractional indexing?
  • Are creating/deleting/restoring hooks registered, and do they behave correctly with soft deletes?
  • Does it support bulk/drag-and-drop reordering (array of IDs → positions) or only single-step up/down?
  • What are the illuminate/* and PHP version constraints, and is there a test suite?
  • How does it compare to spatie/eloquent-sortable, the de facto standard with orders-of-magnitude more adoption?

Integration Approach

Stack fit. Framework-agnostic within Laravel: it depends only on Eloquent, so it slots into monoliths, modular monoliths, and API-only services alike. No frontend or queue assumptions. This makes it a low-blast-radius addition — reversible by dropping the trait and column.

Migration path. Treat it as a schema-plus-behavior change, not a library install:

  1. Add a nullable, indexed positional column (plus a composite unique index on (scope_columns, position) if scoping is supported).
  2. Backfill deterministically from the existing sort key, in a single ordered UPDATE/batch job, inside a transaction.
  3. Attach the trait behind a feature flag on one low-risk model first (e.g., FAQ entries), not on the highest-traffic ordered table.
  4. If replacing an existing manual order column, run a dual-write window where both old and new columns are maintained, then cut reads over, then drop the old column.

Compatibility. Verify the illuminate/support constraint line actually covers the target Laravel major (packages of this vintage frequently cap at older versions). Confirm PHP version parity with CI. Check for collisions with any existing model observers, global scopes, or a competing sortable package already in the dependency tree — two traits both writing a position column will corrupt data silently. Also confirm behavior with withoutEvents() bulk inserts, seeders, and factories, which bypass model events and will not populate positions.

Sequencing.

  1. Source audit + composer constraint check (0.5 day).
  2. Side-by-side comparison against spatie/eloquent-sortable on scoping, concurrency, and bulk reorder (0.5 day).
  3. Spike in a non-production branch on the target Laravel version, including a concurrency test with parallel reorders (1–2 days).
  4. Decision gate: adopt as-is, fork/vendor the trait internally, or rewrite the ~100 lines in-house.
  5. Ship to one model behind a flag, instrument, then expand.

Given the adoption signal, the default recommendation for most teams will be fork or reimplement rather than depend — the package is small enough that ownership cost is low and supply-chain risk drops to zero.

Operational Impact

Maintenance. This is the dominant operational concern. A single-maintainer package with 2 stars should be assumed unmaintained. Pin the exact version, vendor the source into the repo or an internal Composer registry, and assign a named internal owner. Budget a recurring line item for compatibility patches on each Laravel major upgrade.

Support. There is no meaningful community to escalate to. All support is internal: the team owning the model owns the behavior. Document the consumed API surface (trait methods, column name, event hooks) so a future engineer can replace the package without archaeology.

Scaling. The failure mode to watch is reorder cost as list size grows. Full-set reindexing is fine for dozens of rows and pathological for tens of thousands — it serializes writes and holds locks. If any target list can plausibly exceed a few hundred items, require a gap/fractional-position strategy or batch reindexing in a queued job. Also consider read amplification: every ordered query now sorts on the position column, so the index matters.

Failure modes to monitor.

  • Duplicate or null positions after concurrent reorders or event-bypassing bulk inserts.
  • Orphaned/gapped positions after hard or soft deletes.
  • Cross-scope leakage if ordering is global where it should be per-parent or per-tenant.
  • Silent no-ops when the trait is attached but the column is missing or misnamed.
  • Lock contention/timeouts during bulk drag-and-drop saves.

Instrument with a periodic integrity check (duplicate-position and gap queries) and alert on reorder latency.

Ramp-up. The API surface is tiny, so a mid-level engineer can be productive in under a day — but only by reading source, since documentation is likely minimal. Plan for 1–2 days of onboarding that includes writing the missing tests (position assignment on create, reorder, delete, concurrent move, scoped ordering) as a condition of adoption. Those tests are also the artifact that makes a future fork or replacement safe.

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.
adachsoft/changelog-linter
adachsoft/collection
payerurl/telegrambot-crypto-payment-instant-payout
dskripchenko/laravel-hybrid-search
riorizkyrainey/lara-ced
mehedimi/static-vel
zharp/zharp
nonsapiens/bigquery-model-sync
lgu-bayambang-ict-office/lgu-laravel-development-standards
andydefer/laravel-support
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel
draftsmaninc/draftsman
square-bit/laravel-volition
himito/laravel-mailman
htinlynn/genius-helper
maco-studios/hephaestus
elmogy/larafast