trait Sortable

Sortable model trait

Usage:

Model table must have priority table column.

In the model class definition:

use \Igniter\Flame\Database\Traits\Sortable;

To set orders:

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

You can change the sort field used by declaring:

public $sortable [ 'sortOrderColumn' = 'priority', 'sortWhenCreating' = FALSE, ];

Methods

static void
bootSortable()

Boot the sortable trait for this model.

scopeSorted($query)

No description

setSortableOrder($itemIds, null $itemOrders = null)

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

string
getSortOrderColumn()

Get the name of the "sort order" column.

sortWhenCreating()

No description

Details

at line 36
static void bootSortable()

Boot the sortable trait for this model.

Return Value

void

at line 48
scopeSorted($query)

No description

Parameters

$query

at line 62
setSortableOrder($itemIds, null $itemOrders = null)

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

Parameters

$itemIds
null $itemOrders

Exceptions

Exception

at line 85
string getSortOrderColumn()

Get the name of the "sort order" column.

Return Value

string

at line 90
sortWhenCreating()

No description