Sortable
Sortable model trait
Usage:
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';
Table of Contents
- bootSortable() : void
- Boot the sortable trait for this model.
- getSortOrderColumn() : string
- Get the name of the "sort order" column.
- setSortableOrder() : void
- Sets the sort order of records to the specified orders. If the orders is undefined, the record identifier is used.
Methods
bootSortable()
Boot the sortable trait for this model.
public
static bootSortable() : void
Return values
void —getSortOrderColumn()
Get the name of the "sort order" column.
public
getSortOrderColumn() : string
Return values
string —setSortableOrder()
Sets the sort order of records to the specified orders. If the orders is undefined, the record identifier is used.
public
setSortableOrder(mixed $itemIds[, array<string|int, mixed> $itemOrders = null ]) : void
Parameters
- $itemIds : mixed
- $itemOrders : array<string|int, mixed> = null