Implement grouping for sortable models
mainIf your sorting should be scoped to a specific group (e.g., a user_id), implement the buildSortQuery method in your model. This method should return a query builder that includes the necessary constraints to restrict sorting calculations to that group.
// MyModel.php
public function buildSortQuery()
{
return static::query()->where('user_id', $this->user_id);
}