Sorting feature of this package is in its infancy and subject to changes.

  • Use Sortable trait.
  • Define allowedSorts() method.
use IndexZer0\EloquentFiltering\Sort\Traits\Sortable;
use IndexZer0\EloquentFiltering\Sort\Sortable\Sort;

class Product extends Model
{
    use Sortable;

    public function allowedSorts(): AllowedSortList
    {
        return Sort::only(
            Sort::field('name'),
        );
    }
}