Weave Code
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

Orderly Laravel Package

baril/orderly

Add sortable, orderable behavior to Laravel Eloquent models. Store a position column (default: position), use the Orderable trait, and move records with helpers like moveToOffset() and moveToStart(). Supports Laravel 6–12 with version mapping.

View on GitHub
Deep Wiki
Context7

This package adds an orderable/sortable behavior to Eloquent models.

Frequently asked questions about Orderly
How do I install and set up baril/orderly for a Laravel project?
Run `composer require baril/orderly`, add the service provider to `config/app.php`, then add a `position` column (or custom name) to your table via a migration. Finally, use the `Orderable` trait in your Eloquent model and guard the position column.
Does baril/orderly work with Laravel 12, or only older versions?
Yes, baril/orderly supports Laravel 6 through 12 with version-specific releases. Check the [compatibility table](https://github.com/michaelbaril/orderly) to match your Laravel version with the correct package version.
Can I use this package for grouped ordering (e.g., sorting items within categories)?
Absolutely. baril/orderly supports grouped ordering by defining a `$groupColumn` in your model. This allows you to maintain separate order sequences for different categories or sections.
What happens if I try to move a record without saving it first?
The package will throw an error or silently fail, depending on your Laravel configuration. Always ensure the model is persisted before calling methods like `moveToOffset()` or `moveUp()` to avoid orphaned positions.
Is there a way to optimize performance for large datasets (e.g., 50K+ rows)?
For large datasets, add an index on the `position` column and consider batching updates. The package doesn’t natively support transactions for bulk operations, so you may need to wrap `saveOrder()` calls in a database transaction manually.
How do I handle concurrent edits or race conditions in production?
baril/orderly doesn’t include optimistic locking by default. To prevent race conditions, use database transactions or add a `version` column to your model and implement `SELECT ... FOR UPDATE` in critical paths.
Can I use a custom column name instead of `position` for storing order?
Yes, define a `$orderColumn` property in your model (e.g., `protected $orderColumn = 'sort_order';`). This is useful if `position` conflicts with existing schema or naming conventions.
Does this package work with multi-database setups (e.g., MySQL + PostgreSQL)?
Yes, baril/orderly is database-agnostic and supports MySQL, PostgreSQL, SQLite, and SQL Server (since v3.3.0). The same codebase works across databases without modifications.
Is there a way to fix corrupted or missing position values in production?
Yes, the package includes an Artisan command: `php artisan orderly:fix-positions`. This tool scans your table and regenerates positions, ensuring continuity after data corruption or manual deletions.
What alternatives exist for ordering Eloquent models, and when should I consider them?
Alternatives include custom solutions with a separate `order` table or packages like `spatie/laravel-activitylog` for hierarchical data. Use baril/orderly for simple drag-and-drop UIs; opt for alternatives if you need real-time updates (e.g., PostgreSQL LISTEN/NOTIFY) or complex hierarchies (e.g., tree structures).
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.
besmartand-pro/php-quality-config
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity