Livewire

Building a Drag and Drop List with Livewire v4

February 01, 2026 1 min read 25 views

Build a sortable list with SortableJS.

Component

@php
new class extends Livewire\Component {
    public array $items = [];
    
    public function updateOrder(array $order): void
    {
        foreach ($order as $position => $id) {
            Item::find($id)->update(['position' => $position]);
        }
    }
}
@endphp

@foreach($items as $item)
{{ $item->name }}
@endforeach
Share this post:

Related Posts

Comments (0)

Please log in to leave a comment. Log in

No comments yet. Be the first to comment!