Sortable model trait


Model table must have sort_order table column.

In the model class definition:

use \October\Rain\Database\Traits\Sortable;

To set orders:

$model->setSortableOrder($recordIds, $recordOrders);

You can change the sort field used by declaring:

const SORT_ORDER = 'my_sort_order';

Public methods

public static void bootSortable()

Boot the sortable trait for this model.

public string getSortOrderColumn()

Get the name of the "sort order" column.

public void setSortableOrder(mixed $itemIds, array $itemOrders=NULL)

Sets the sort order of records to the specified orders. If the orders is undefined, the record identifier is used.

  • mixed $itemIds
  • array $itemOrders