Fix sort_order: sequential 1,2,3 + renormalize after every save
- saving: always shift >= new position by +1 (no conflict check needed) - saved: renormalize all records to 1, 2, 3... via direct DB update (no model events triggered) to close any gaps left by the move - Migration updated to use step 1 instead of 10 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -19,7 +19,7 @@ return new class extends Migration
|
||||
foreach ($rows as $i => $id) {
|
||||
DB::table('labor_categories')
|
||||
->where('id', $id)
|
||||
->update(['sort_order' => ($i + 1) * 10]);
|
||||
->update(['sort_order' => $i + 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user