In this episode, we're diving into making our Eloquent models sortable using the Eloquent Sortable package. First, we discuss why you'd want to use this package to keep the order of your columns and cards exactly as intended in your app, especially when users start dragging and dropping stuff around.
We walk through installing the package, publishing the config (which is optional but helpful), and then head into our models — like columns and cards — to implement the sortable interface and pull in the sortable trait. We go step-by-step setting up the required configuration, such as specifying our order column and ensuring new items are sorted on creation.
Finally, we update our queries in controllers and Livewire components to fetch ordered results automatically. By the end of this video, our columns and cards show up in the right order, and we're all set up to push any changes back to the database after drag-and-drop operations. Super handy for keeping your UI and data perfectly in sync!