đź§© How to Use reorderable() with Pivot Table Columns in Many-to-Many Relationships?
Hi! I’m trying to implement row reordering using Filament’s
->reorderable()
method, but the order I need to update lives in a pivot table of a many-to-many relationship.
Has anyone successfully used ->reorderable()
to update an order
column in a pivot table?
For example, suppose we have Project
and Task
models with a many-to-many relationship, and the pivot table project_task
contains an order
column. I want to be able to reorder tasks within a project and have it update project_task.order
.
What would be the correct approach to get reordering to work in this kind of setup?
Any small working example or tip would be really appreciated. 🙏1 Reply
iirc you only need to add
->reorderable('order')
to the relation manager's table and ->withPivot('order')
to its model's relation