In this episode, we tackle the popular need of making models sortable in Laravel Nova. We start from scratch with a fresh Laravel Nova install (with basic models already set up), and focus on a pretty common use case: sorting episodes within a course (one-to-many relationship).
You'll see how we create Nova resources both for the course and its episodes, link them up with the right relationships, and even output a list of episodes onto a dashboard page to keep track of our sorting progress.
The core of the episode is all about installing and setting up two helpful packages: eloquent-sortable
(to handle the backend ordering) and nova-sortable
(to give us that sweet drag-and-drop functionality right in Nova's interface). We cover how to update your database with an order
column, use the necessary traits, and configure everything so you get smooth, reliable sorting.
By the end, you’ll see how easily you can reorder episodes in a Nova HasMany field, and that changes are reflected everywhere in your app. We also briefly mention that both packages come with extra configuration options if you need more advanced sorting down the line. So if you want to make your models sortable in Laravel Nova, this video has you covered step by step!