Sortable

Sortable model trait

 trait Winter\Storm\Database\Traits\Sortable

Usage:

Model table must have sort_order table column.

In the model class definition:

use \Winter\Storm\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';

Methods

public static bootSortable () : void

Boot the sortable trait for this model.

Returns
void

public getSortOrderColumn () : string

Get the name of the "sort order" column.

Returns
string

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

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

Parameters
Property Description
$itemIds
mixed
$itemOrders
array
Returns
void
Copyright © 2024 Winter CMS