Pros:
ItemsReordered events, enabling extensibility (e.g., logging, notifications, or syncing with external systems).moveToPosition() and reorderFromArray() for backend-driven reordering (e.g., migrations, admin actions).Cons:
sort_order), which may not align with existing schema designs (e.g., apps using position or priority).reorderFromArray() updates all items in a group in a single transaction, but large datasets (e.g., >10K items) could cause timeouts or lock contention.ordered() scope adds a ORDER BY clause, which may impact query performance if the sort column is not indexed (the package assumes an index exists).authorize config callback is optional, leaving apps vulnerable to unauthorized reordering if not implemented.Schema compatibility:
sort_order, position), or will a migration be required?Performance requirements:
project_id)?UI/UX priorities:
Authorization:
authorize callback be implemented (e.g., Gates, Policies)?Event handling:
ItemsReordered event be consumed?Testing:
moveToPosition(), E2E tests for UI)?/reorderable/demo) be enabled for testing?Fallbacks:
@livewireStyles/@livewireScripts in layouts.@stack('scripts') for JavaScript.sort_order) with an index. Supports PostgreSQL, MySQL, SQLite.Schema Update:
sort_order) to the target table with an index.Schema::table('tasks', function (Blueprint $table) {
$table->unsignedInteger('sort_order')->default(0)->index();
});
Model Integration:
HasSortOrder trait and implement ReorderableContract.$sortColumn if using a non-default column name.getReorderLabel() for custom display text.getDefaultReorderGroupColumn().Configuration:
php artisan reorderable:install to publish config/views.config/reorderable.php (recommended for security).authorize callback if row-level security is needed.UI Integration:
@include('reorderable::components.list') directive in views, passing required props (items, modelClass, etc.).<livewire:reorderable-list> component in Livewire-driven pages.<meta name="csrf-token" content="{{ csrf_token() }}">.@stack('scripts') (Blade) or @livewireScripts (Livewire).Routing:
POST /reorderable/update) for handling reorder requests. No custom routes are needed unless changing route_prefix.Testing:
ordered() scope to ensure correct sorting.ordered() scope is opt-in.Phase 1: Setup and Configuration
Phase 2: Model Integration
Task, Post).getReorderLabel(), etc.).Phase 3: UI Implementation
Phase 4: Backend Logic
moveToPosition() in admin actions).ItemsReordered if needed.Phase 5: Testing and Optimization
Phase 6: Rollout
atomcoder/laravel-reorderable (MIT license allows forks if needed).How can I help you explore Laravel packages today?